@wix/himalaya-cli 0.1544.0 → 0.1546.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 (227) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/agent/src/index.d.ts +5 -2
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/state/src/index.d.ts +14 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/state/src/read.d.ts +60 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/activity-counters-v1/src/index.d.ts +19 -0
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ai-site-chat/src/index.d.ts +19 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/analytics/src/index.d.ts +42 -2
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/async-jobs/src/index.d.ts +19 -0
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/automations-v1/src/index.d.ts +19 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/badges-v2/src/index.d.ts +19 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/billing-tax-v1/src/index.d.ts +19 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/blog-v3/src/extensions.d.ts +5 -4
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/blog-v3/src/index.d.ts +19 -0
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/bookings-v2/src/extensions.d.ts +4 -4
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/bookings-v2/src/index.d.ts +19 -0
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/business-feed/src/index.d.ts +11 -0
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/business-tools-v1/src/index.d.ts +19 -0
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/chat-web/src/index.d.ts +22 -1
  18. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/comments-v1/src/index.d.ts +19 -0
  19. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/contacts/src/index.d.ts +19 -0
  20. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/coupons/src/index.d.ts +24 -2
  21. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/crm-tasks/src/index.d.ts +11 -0
  22. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/dashboard-setup/src/index.d.ts +11 -0
  23. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/data-collections-v1/src/index.d.ts +19 -0
  24. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/donations/src/index.d.ts +19 -0
  25. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ecom/src/extensions.d.ts +6 -5
  26. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/ecom/src/index.d.ts +19 -0
  27. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/email-marketing-v1/src/index.d.ts +19 -0
  28. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/events/src/index.d.ts +24 -2
  29. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/faq-v2/src/index.d.ts +19 -0
  30. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/forms/src/index.d.ts +19 -0
  31. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/forum/src/index.d.ts +19 -0
  32. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/genie-chat/src/index.d.ts +11 -0
  33. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/gift-cards/src/index.d.ts +19 -0
  34. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/groups/src/index.d.ts +19 -0
  35. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/inbox/src/extensions.d.ts +2 -1
  36. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/inbox/src/index.d.ts +19 -0
  37. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/invoices/src/index.d.ts +24 -2
  38. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/loyalty/src/index.d.ts +28 -4
  39. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/marketing-v1/src/index.d.ts +19 -0
  40. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-feed-viewer/src/index.d.ts +23 -1
  41. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/members-v1/src/index.d.ts +25 -3
  42. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/new-releases/src/index.d.ts +23 -1
  43. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/notification-preferences/src/index.d.ts +23 -2
  44. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/notifications-v3/src/index.d.ts +19 -0
  45. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/online-programs/src/index.d.ts +25 -3
  46. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/portfolio/src/index.d.ts +25 -3
  47. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/pricing-plans/src/index.d.ts +28 -6
  48. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/redirects-v1/src/index.d.ts +19 -0
  49. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/restaurants/src/extensions.d.ts +2 -2
  50. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/restaurants/src/index.d.ts +19 -0
  51. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/reviews/src/index.d.ts +24 -2
  52. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/seo-v1/src/index.d.ts +19 -0
  53. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/site-list/src/index.d.ts +19 -0
  54. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/site-media/src/index.d.ts +11 -0
  55. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/social-feed/src/index.d.ts +23 -1
  56. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-collections/src/display.d.ts +3 -2
  57. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-collections/src/index.d.ts +27 -3
  58. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-v1/src/catalog.d.ts +7 -7
  59. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-v1/src/display.d.ts +4 -3
  60. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-v1/src/extensions.d.ts +2 -1
  61. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-v1/src/index.d.ts +19 -0
  62. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/table-reservations/src/index.d.ts +25 -3
  63. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/users/src/index.d.ts +23 -1
  64. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/video/src/index.d.ts +19 -0
  65. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/wix-data/src/index.d.ts +27 -3
  66. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/workflows-v1/src/index.d.ts +19 -0
  67. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk-auto/_shared/runtime.generated.d.ts +8 -0
  68. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/checkout.mjs +12 -4
  69. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +36 -11
  70. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/state.mjs +206 -12
  71. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-activity-counters.mjs +19 -5
  72. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-ai-site-chat.mjs +19 -5
  73. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-analytics.mjs +21 -7
  74. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-async-jobs.mjs +19 -5
  75. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-automations.mjs +19 -5
  76. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-badges.mjs +19 -5
  77. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-billing-tax.mjs +19 -5
  78. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-blog.mjs +31 -14
  79. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-bookings.mjs +26 -12
  80. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-business-tools.mjs +20 -6
  81. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-chat-web.mjs +29 -7
  82. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-comments.mjs +28 -5
  83. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-contacts.mjs +19 -5
  84. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-coupons.mjs +14 -6
  85. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-data-collections.mjs +19 -5
  86. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-data.mjs +15 -5
  87. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-donations.mjs +19 -5
  88. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-ecom.mjs +33 -16
  89. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-email-marketing.mjs +19 -5
  90. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-events.mjs +14 -6
  91. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-faq.mjs +20 -6
  92. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-forms.mjs +19 -5
  93. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-forum.mjs +19 -5
  94. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-gift-cards.mjs +19 -5
  95. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-groups.mjs +19 -5
  96. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-inbox.mjs +21 -7
  97. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-invoices.mjs +14 -6
  98. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-loyalty.mjs +16 -8
  99. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-marketing.mjs +19 -5
  100. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members-feed-viewer.mjs +21 -10
  101. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-members.mjs +17 -8
  102. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-new-releases.mjs +17 -5
  103. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-notification-preferences.mjs +20 -6
  104. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-notifications.mjs +19 -5
  105. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-online-programs.mjs +16 -8
  106. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-portfolio.mjs +16 -8
  107. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-pricing-plans.mjs +22 -14
  108. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-redirects.mjs +19 -5
  109. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-restaurants.mjs +22 -7
  110. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-reviews.mjs +14 -6
  111. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-rich-content-editor.mjs +3 -0
  112. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-seo.mjs +19 -5
  113. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-site-list.mjs +19 -5
  114. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-social-feed.mjs +15 -5
  115. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-stores-collections.mjs +20 -10
  116. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-stores.mjs +116 -83
  117. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-table-reservations.mjs +16 -8
  118. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-users.mjs +15 -5
  119. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-video.mjs +9 -1
  120. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/wix-workflows.mjs +19 -5
  121. package/dist/cli.mjs +1002 -806
  122. package/dist/preview-assets.generated.bin +0 -0
  123. package/fixtures/wix-canned.json +8 -8
  124. package/guides/dynamic-list.service.ts +38 -29
  125. package/guides/form-submit.service.ts +2 -1
  126. package/guides/himi-json-output.md +29 -0
  127. package/guides/iap-products.md +49 -4
  128. package/guides/index.json +6 -0
  129. package/guides/offline-reading.md +63 -0
  130. package/guides/recipe-dynamic-list.md +2 -0
  131. package/guides/recipe-four-state.md +1 -0
  132. package/guides/sdk-reference.json +225 -99
  133. package/guides/testing-himi-apps.md +2 -0
  134. package/guides/tier-5-add-a-screen.md +2 -0
  135. package/package.json +2 -2
  136. package/templates/beauty-salon/dev/index.ts +4 -3
  137. package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +6 -9
  138. package/templates/beauty-salon/tier5-src/_shared/iap-presentation.ts +7 -3
  139. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +1 -1
  140. package/templates/beauty-salon/tier5-src/himi-branded-lite-orders/index.ts +3 -0
  141. package/templates/beauty-salon-owner/dev/index.ts +19 -19
  142. package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +6 -9
  143. package/templates/beauty-salon-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  144. package/templates/branded-lite/dev/index.ts +38 -20
  145. package/templates/branded-lite/tier5-src/_shared/collection-query-legacy.ts +194 -0
  146. package/templates/branded-lite/tier5-src/_shared/collection-query.ts +158 -99
  147. package/templates/branded-lite/tier5-src/_shared/collection-service.ts +31 -11
  148. package/templates/branded-lite/tier5-src/_shared/iap-presentation.ts +7 -3
  149. package/templates/branded-lite/tier5-src/_shared/read-service.ts +255 -0
  150. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +1 -1
  151. package/templates/branded-lite/tier5-src/himi-branded-lite-orders/index.ts +3 -0
  152. package/templates/branded-lite/tier5-src/himi-branded-lite-shop/index.ts +202 -159
  153. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +130 -201
  154. package/templates/community-club/dev/index.ts +4 -4
  155. package/templates/community-club/tier5-src/_shared/collection-service.ts +6 -9
  156. package/templates/community-club/tier5-src/_shared/iap-presentation.ts +7 -3
  157. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +1 -1
  158. package/templates/community-club-owner/dev/index.ts +19 -19
  159. package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +6 -9
  160. package/templates/community-club-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  161. package/templates/events-meetups/dev/index.ts +3 -3
  162. package/templates/events-meetups/tier5-src/_shared/collection-service.ts +6 -9
  163. package/templates/events-meetups/tier5-src/_shared/iap-presentation.ts +7 -3
  164. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +1 -1
  165. package/templates/events-meetups-owner/dev/index.ts +17 -17
  166. package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +6 -9
  167. package/templates/events-meetups-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  168. package/templates/gym-fitness/dev/index.ts +5 -4
  169. package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +6 -9
  170. package/templates/gym-fitness/tier5-src/_shared/iap-presentation.ts +7 -3
  171. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +1 -1
  172. package/templates/gym-fitness/tier5-src/himi-branded-lite-orders/index.ts +3 -0
  173. package/templates/gym-fitness-owner/dev/index.ts +20 -20
  174. package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +6 -9
  175. package/templates/gym-fitness-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  176. package/templates/nonprofit-cause/dev/index.ts +4 -4
  177. package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +6 -9
  178. package/templates/nonprofit-cause/tier5-src/_shared/iap-presentation.ts +7 -3
  179. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +1 -1
  180. package/templates/nonprofit-cause-owner/dev/index.ts +18 -18
  181. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +6 -9
  182. package/templates/nonprofit-cause-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  183. package/templates/owner-lite/dev/index.ts +20 -20
  184. package/templates/owner-lite/tier5-src/_shared/collection-service.ts +6 -9
  185. package/templates/owner-lite/tier5-src/_shared/owner-module-data.ts +1 -1
  186. package/templates/podcast-creator/dev/index.ts +4 -4
  187. package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +6 -9
  188. package/templates/podcast-creator/tier5-src/_shared/iap-presentation.ts +7 -3
  189. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +1 -1
  190. package/templates/podcast-creator-owner/dev/index.ts +19 -19
  191. package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +6 -9
  192. package/templates/podcast-creator-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  193. package/templates/portfolio-creative/dev/index.ts +5 -4
  194. package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +6 -9
  195. package/templates/portfolio-creative/tier5-src/_shared/iap-presentation.ts +7 -3
  196. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +1 -1
  197. package/templates/portfolio-creative/tier5-src/himi-branded-lite-orders/index.ts +3 -0
  198. package/templates/portfolio-creative-owner/dev/index.ts +19 -19
  199. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +6 -9
  200. package/templates/portfolio-creative-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  201. package/templates/restaurant/dev/index.ts +3 -3
  202. package/templates/restaurant/tier5-src/_shared/collection-service.ts +6 -9
  203. package/templates/restaurant/tier5-src/_shared/iap-presentation.ts +7 -3
  204. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +1 -1
  205. package/templates/restaurant-owner/dev/index.ts +20 -20
  206. package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +6 -9
  207. package/templates/restaurant-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  208. package/templates/retail-store/dev/index.ts +19 -1
  209. package/templates/retail-store/tier5-src/_shared/collection-query-legacy.ts +194 -0
  210. package/templates/retail-store/tier5-src/_shared/collection-query.ts +158 -99
  211. package/templates/retail-store/tier5-src/_shared/collection-service.ts +31 -11
  212. package/templates/retail-store/tier5-src/_shared/iap-presentation.ts +7 -3
  213. package/templates/retail-store/tier5-src/_shared/read-service.ts +255 -0
  214. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +1 -1
  215. package/templates/retail-store/tier5-src/himi-branded-lite-orders/index.ts +3 -0
  216. package/templates/retail-store/tier5-src/himi-branded-lite-shop/index.ts +202 -159
  217. package/templates/retail-store/tier5-src/himi-store-product/index.ts +130 -201
  218. package/templates/retail-store-owner/dev/index.ts +18 -18
  219. package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +6 -9
  220. package/templates/retail-store-owner/tier5-src/_shared/owner-module-data.ts +1 -1
  221. package/templates/yoga-studio/dev/index.ts +4 -4
  222. package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +6 -9
  223. package/templates/yoga-studio/tier5-src/_shared/iap-presentation.ts +7 -3
  224. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +1 -1
  225. package/templates/yoga-studio-owner/dev/index.ts +18 -18
  226. package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +6 -9
  227. package/templates/yoga-studio-owner/tier5-src/_shared/owner-module-data.ts +1 -1
@@ -1,3 +1,204 @@
1
+ // ../../core/sdk/state/src/connectivity.ts
2
+ function connectivity() {
3
+ const host = globalThis.himalaya;
4
+ if (!host?.connectivity?.current) throw new Error("CONNECTIVITY_UNSUPPORTED: update the Himalaya runtime before installing this screen");
5
+ const current = host.connectivity.current();
6
+ if (typeof current?.online !== "boolean") throw new Error("CONNECTIVITY_UNSUPPORTED: this host cannot report connectivity");
7
+ return current;
8
+ }
9
+ function requireConnectivity() {
10
+ if (!connectivity().online) throw new Error("You\u2019re offline \u2014 this change can\u2019t be saved right now. Connect and try again.");
11
+ }
12
+
13
+ // ../../core/sdk/state/src/read.ts
14
+ var initialReadStatus = () => ({
15
+ hasSnapshot: false,
16
+ fromCache: false,
17
+ refreshing: false,
18
+ stale: false,
19
+ offline: false,
20
+ error: ""
21
+ });
22
+ function createReadController(options) {
23
+ let key = "", generation = 0, disposed = false;
24
+ let data, metadata, status = initialReadStatus();
25
+ let pending;
26
+ let expiryTimer;
27
+ const now = options.now ?? Date.now;
28
+ const online = options.online ?? (() => connectivity().online);
29
+ const expire = () => {
30
+ if (status.hasSnapshot && !online() && metadata?.source !== "local" && (!metadata?.cacheable || metadata.expiresAt === void 0 || metadata.expiresAt <= now())) {
31
+ data = void 0;
32
+ metadata = void 0;
33
+ status = { ...initialReadStatus(), offline: true };
34
+ }
35
+ };
36
+ const emit = () => {
37
+ if (expiryTimer !== void 0 && typeof globalThis.clearTimeout === "function") globalThis.clearTimeout(expiryTimer);
38
+ expiryTimer = void 0;
39
+ if (disposed) return;
40
+ expire();
41
+ status = { ...status, expiresAt: metadata?.cacheable ? metadata.expiresAt : void 0 };
42
+ options.publish(data, { ...status });
43
+ if (!online() && status.hasSnapshot && metadata && metadata.source !== "local" && metadata.cacheable && metadata.expiresAt !== void 0 && typeof globalThis.setTimeout === "function") {
44
+ expiryTimer = globalThis.setTimeout(emit, Math.min(2147483647, Math.max(1, metadata.expiresAt - now())));
45
+ expiryTimer.unref?.();
46
+ }
47
+ };
48
+ const run = async (revision, readKey) => {
49
+ const current = () => !disposed && revision === generation;
50
+ status = { ...status, refreshing: online(), offline: !online(), error: "" };
51
+ emit();
52
+ if (!status.hasSnapshot && options.cached) {
53
+ const cached = await options.cached(readKey).catch(() => void 0);
54
+ if (!current()) return;
55
+ if (cached && (options.allowLocal && cached.metadata.source === "local" || cached.metadata.source === "cache" && cached.metadata.cacheable && cached.metadata.expiresAt !== void 0 && cached.metadata.expiresAt > now())) {
56
+ data = cached.data;
57
+ metadata = cached.metadata;
58
+ const local = metadata.source === "local";
59
+ status = {
60
+ ...status,
61
+ hasSnapshot: true,
62
+ hasLocalContent: local,
63
+ fromCache: !local,
64
+ stale: !local,
65
+ lastSuccessAt: local ? void 0 : metadata.fetchedAt
66
+ };
67
+ emit();
68
+ } else {
69
+ emit();
70
+ }
71
+ }
72
+ if (!online()) {
73
+ if (current()) {
74
+ status = { ...status, refreshing: false, offline: true, stale: status.hasSnapshot && !status.hasLocalContent };
75
+ emit();
76
+ }
77
+ return;
78
+ }
79
+ if (!status.refreshing || status.offline) {
80
+ status = { ...status, refreshing: true, offline: false };
81
+ emit();
82
+ }
83
+ try {
84
+ const next = await options.fetch(readKey);
85
+ if (!current()) return;
86
+ if (next.metadata.source !== "network" && !(options.allowLocal && next.metadata.source === "local")) throw new Error("The refresh did not reach the server. Try again.");
87
+ data = next.data;
88
+ metadata = next.metadata;
89
+ const local = metadata.source === "local";
90
+ status = {
91
+ hasSnapshot: true,
92
+ hasLocalContent: local,
93
+ fromCache: false,
94
+ refreshing: false,
95
+ stale: !local && !online(),
96
+ offline: !online(),
97
+ lastSuccessAt: local ? void 0 : next.metadata.fetchedAt,
98
+ error: ""
99
+ };
100
+ } catch (error) {
101
+ if (!current()) return;
102
+ if (options.clearOnError?.(error)) {
103
+ data = void 0;
104
+ metadata = void 0;
105
+ status = initialReadStatus();
106
+ }
107
+ const retained = status.hasSnapshot && !status.hasLocalContent;
108
+ status = {
109
+ ...status,
110
+ refreshing: false,
111
+ stale: retained,
112
+ offline: !online(),
113
+ error: retained ? "Couldn\u2019t refresh. Content may be outdated." : status.hasSnapshot ? "Couldn\u2019t refresh. Try again." : options.errorMessage?.(error) || "This content could not load. Try again."
114
+ };
115
+ }
116
+ emit();
117
+ };
118
+ const load = (nextKey) => {
119
+ if (disposed) return Promise.resolve();
120
+ if (nextKey === key && pending) return pending;
121
+ if (nextKey !== key) {
122
+ key = nextKey;
123
+ data = void 0;
124
+ metadata = void 0;
125
+ status = initialReadStatus();
126
+ }
127
+ const revision = ++generation;
128
+ const task = run(revision, key).finally(() => {
129
+ if (generation === revision) pending = void 0;
130
+ });
131
+ pending = task;
132
+ return task;
133
+ };
134
+ const controller = {
135
+ load,
136
+ refresh: () => load(key),
137
+ getStatus: () => ({ ...status }),
138
+ /** Revision for adapters that coalesce the read and their final state projection. */
139
+ getRevision: () => generation,
140
+ connectivityChanged(connected) {
141
+ if (!connected) {
142
+ generation++;
143
+ pending = void 0;
144
+ if (metadata?.source !== "local" && (!metadata?.cacheable || metadata.expiresAt === void 0 || metadata.expiresAt <= now())) {
145
+ data = void 0;
146
+ metadata = void 0;
147
+ status = initialReadStatus();
148
+ }
149
+ }
150
+ status = {
151
+ ...status,
152
+ offline: !connected,
153
+ refreshing: connected && status.refreshing,
154
+ stale: status.hasSnapshot && (status.stale || !connected && metadata?.source !== "local")
155
+ };
156
+ emit();
157
+ if (!connected && !status.hasSnapshot && key && options.cached) void load(key);
158
+ },
159
+ replace(snapshot, nextKey) {
160
+ generation++;
161
+ pending = void 0;
162
+ if (nextKey !== void 0) key = nextKey;
163
+ data = snapshot.data;
164
+ metadata = snapshot.metadata;
165
+ status = {
166
+ hasSnapshot: true,
167
+ fromCache: snapshot.metadata.source === "cache",
168
+ refreshing: false,
169
+ stale: snapshot.metadata.source === "cache" || !online(),
170
+ offline: !online(),
171
+ lastSuccessAt: snapshot.metadata.fetchedAt,
172
+ error: ""
173
+ };
174
+ emit();
175
+ },
176
+ invalidate() {
177
+ generation++;
178
+ pending = void 0;
179
+ data = void 0;
180
+ metadata = void 0;
181
+ status = initialReadStatus();
182
+ emit();
183
+ },
184
+ dispose() {
185
+ disposed = true;
186
+ generation++;
187
+ pending = void 0;
188
+ if (expiryTimer !== void 0 && typeof globalThis.clearTimeout === "function") globalThis.clearTimeout(expiryTimer);
189
+ unsubscribe?.();
190
+ }
191
+ };
192
+ const host = globalThis.himalaya;
193
+ const unsubscribe = host?.__subscribeReadLifecycle?.((signal) => {
194
+ if (signal === "check") emit();
195
+ else if (signal === "invalidate") controller.invalidate();
196
+ else if (signal === "dispose") controller.dispose();
197
+ else controller.connectivityChanged(signal === "online");
198
+ });
199
+ return controller;
200
+ }
201
+
1
202
  // ../../core/ts/src/validation.ts
2
203
  var EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
3
204
  var URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
@@ -181,18 +382,6 @@ function validateAll(rules, values, catalog) {
181
382
  return errors;
182
383
  }
183
384
 
184
- // ../../core/sdk/state/src/connectivity.ts
185
- function connectivity() {
186
- const host = globalThis.himalaya;
187
- if (!host?.connectivity?.current) throw new Error("CONNECTIVITY_UNSUPPORTED: update the Himalaya runtime before installing this screen");
188
- const current = host.connectivity.current();
189
- if (typeof current?.online !== "boolean") throw new Error("CONNECTIVITY_UNSUPPORTED: this host cannot report connectivity");
190
- return current;
191
- }
192
- function requireConnectivity() {
193
- if (!connectivity().online) throw new Error("You\u2019re offline \u2014 this change can\u2019t be saved right now. Connect and try again.");
194
- }
195
-
196
385
  // ../../core/sdk/state/src/index.ts
197
386
  function withStream(state, directive) {
198
387
  return { ...state, _stream: directive };
@@ -243,6 +432,9 @@ function defineService(name, def) {
243
432
  "@himalaya/state: defineService called outside a Himalaya runtime. This bundle must run inside a JSWorker (Tier 5)."
244
433
  );
245
434
  }
435
+ if (def.readLifecycle && (himalaya.readLifecycleVersion ?? 0) < 1) {
436
+ throw new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime before installing this screen");
437
+ }
246
438
  return himalaya.defineService(name, def);
247
439
  }
248
440
  var APP_SERVICE_CODES = /* @__PURE__ */ new Set([
@@ -364,8 +556,10 @@ export {
364
556
  app,
365
557
  classifyLoadError,
366
558
  connectivity,
559
+ createReadController,
367
560
  defineService,
368
561
  encodeSubtree,
562
+ initialReadStatus,
369
563
  isAppServiceError,
370
564
  isValid as isValidValue,
371
565
  navigate,
@@ -11,12 +11,26 @@ function wixCall(method, path, body, opts) {
11
11
  )
12
12
  );
13
13
  }
14
- return globalThis.himalaya.wixApi.call(
15
- method,
16
- path,
17
- body,
18
- wixCallHeaders(opts)
14
+ const api = globalThis.himalaya.wixApi;
15
+ const verb = method.toUpperCase();
16
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
17
+ path.split("#")[0]
19
18
  );
19
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
20
+ if (!api.read)
21
+ return Promise.reject(
22
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
23
+ );
24
+ return api.read(method, path, body, wixCallHeaders(opts), {
25
+ cache: opts.cache ?? "default"
26
+ }).then((result) => {
27
+ opts.onCacheResult?.(result.cache);
28
+ return result.data;
29
+ });
30
+ }
31
+ if (opts?.cache === "only-if-cached")
32
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
33
+ return api.call(method, path, body, wixCallHeaders(opts));
20
34
  }
21
35
  function setActivityCounters(memberId, req = {}, opts) {
22
36
  if (!memberId) throw new Error("setActivityCounters: memberId is required");
@@ -16,12 +16,26 @@ function wixCall(method, path, body, opts) {
16
16
  )
17
17
  );
18
18
  }
19
- return globalThis.himalaya.wixApi.call(
20
- method,
21
- path,
22
- body,
23
- wixCallHeaders(opts)
19
+ const api = globalThis.himalaya.wixApi;
20
+ const verb = method.toUpperCase();
21
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
22
+ path.split("#")[0]
24
23
  );
24
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
25
+ if (!api.read)
26
+ return Promise.reject(
27
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
28
+ );
29
+ return api.read(method, path, body, wixCallHeaders(opts), {
30
+ cache: opts.cache ?? "default"
31
+ }).then((result) => {
32
+ opts.onCacheResult?.(result.cache);
33
+ return result.data;
34
+ });
35
+ }
36
+ if (opts?.cache === "only-if-cached")
37
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
38
+ return api.call(method, path, body, wixCallHeaders(opts));
25
39
  }
26
40
  function wixQueryPath(path, req) {
27
41
  const parts = [];
@@ -1,9 +1,19 @@
1
1
  // ../../stdlib/wix-sdk/analytics/src/index.ts
2
- function wixCall(method, path, body) {
2
+ function wixCall(method, path, body, readOptions) {
3
3
  if (!globalThis.himalaya?.wixApi) {
4
- return Promise.reject(new Error("@himalaya/wix-analytics: host did not install the wixApi bridge"));
4
+ return Promise.reject(
5
+ new Error("@himalaya/wix-analytics: host did not install the wixApi bridge")
6
+ );
7
+ }
8
+ const api = globalThis.himalaya.wixApi;
9
+ if (readOptions?.cache || readOptions?.onCacheResult) {
10
+ if (!api.read) return Promise.reject(new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime"));
11
+ return api.read(method, path, body, readOptions.site ? { "wix-site-id": readOptions.site } : void 0, { cache: readOptions.cache ?? "default" }).then((result) => {
12
+ readOptions.onCacheResult?.(result.cache);
13
+ return result.data;
14
+ });
5
15
  }
6
- return globalThis.himalaya.wixApi.call(method, path, body);
16
+ return readOptions?.site ? api.call(method, path, body, { "wix-site-id": readOptions.site }) : api.call(method, path, body);
7
17
  }
8
18
  var YMD = /^(\d{4})-(\d{2})-(\d{2})$/;
9
19
  function hasIntl() {
@@ -110,7 +120,7 @@ function localDateRange(days, ianaZone, today = /* @__PURE__ */ new Date()) {
110
120
  effectiveZone: effectiveZone(ianaZone)
111
121
  };
112
122
  }
113
- function getSiteAnalytics(opts) {
123
+ function getSiteAnalytics(opts, options) {
114
124
  const { startDate, endDate, timeZone, today } = opts;
115
125
  const measurementTypes = opts.measurementTypes ?? ["TOTAL_SESSIONS", "TOTAL_SALES", "TOTAL_ORDERS"];
116
126
  const earliest = earliestAvailableDate(today ?? /* @__PURE__ */ new Date(), timeZone);
@@ -123,13 +133,17 @@ function getSiteAnalytics(opts) {
123
133
  ];
124
134
  return wixCall(
125
135
  "GET",
126
- `/analytics/v2/site-analytics/data?${params.join("&")}`
136
+ `/analytics/v2/site-analytics/data?${params.join("&")}`,
137
+ void 0,
138
+ options
127
139
  );
128
140
  }
129
- function getSiteTimeZone() {
141
+ function getSiteTimeZone(options) {
130
142
  return wixCall(
131
143
  "GET",
132
- "/site-properties/v4/properties?fields.paths=timeZone"
144
+ "/site-properties/v4/properties?fields.paths=timeZone",
145
+ void 0,
146
+ options
133
147
  ).then((r) => r?.properties?.timeZone);
134
148
  }
135
149
  var SEMANTIC_BASE = "/analytics/semantic-model/v3/semantic-models";
@@ -11,12 +11,26 @@ function wixCall(method, path, body, opts) {
11
11
  )
12
12
  );
13
13
  }
14
- return globalThis.himalaya.wixApi.call(
15
- method,
16
- path,
17
- body,
18
- wixCallHeaders(opts)
14
+ const api = globalThis.himalaya.wixApi;
15
+ const verb = method.toUpperCase();
16
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
17
+ path.split("#")[0]
19
18
  );
19
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
20
+ if (!api.read)
21
+ return Promise.reject(
22
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
23
+ );
24
+ return api.read(method, path, body, wixCallHeaders(opts), {
25
+ cache: opts.cache ?? "default"
26
+ }).then((result) => {
27
+ opts.onCacheResult?.(result.cache);
28
+ return result.data;
29
+ });
30
+ }
31
+ if (opts?.cache === "only-if-cached")
32
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
33
+ return api.call(method, path, body, wixCallHeaders(opts));
20
34
  }
21
35
  function getAsyncJob(jobId, opts) {
22
36
  if (!jobId) throw new Error("getAsyncJob: jobId is required");
@@ -11,12 +11,26 @@ function wixCall(method, path, body, opts) {
11
11
  )
12
12
  );
13
13
  }
14
- return globalThis.himalaya.wixApi.call(
15
- method,
16
- path,
17
- body,
18
- wixCallHeaders(opts)
14
+ const api = globalThis.himalaya.wixApi;
15
+ const verb = method.toUpperCase();
16
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
17
+ path.split("#")[0]
19
18
  );
19
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
20
+ if (!api.read)
21
+ return Promise.reject(
22
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
23
+ );
24
+ return api.read(method, path, body, wixCallHeaders(opts), {
25
+ cache: opts.cache ?? "default"
26
+ }).then((result) => {
27
+ opts.onCacheResult?.(result.cache);
28
+ return result.data;
29
+ });
30
+ }
31
+ if (opts?.cache === "only-if-cached")
32
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
33
+ return api.call(method, path, body, wixCallHeaders(opts));
20
34
  }
21
35
  function wixQueryPath(path, req) {
22
36
  const parts = [];
@@ -11,12 +11,26 @@ function wixCall(method, path, body, opts) {
11
11
  )
12
12
  );
13
13
  }
14
- return globalThis.himalaya.wixApi.call(
15
- method,
16
- path,
17
- body,
18
- wixCallHeaders(opts)
14
+ const api = globalThis.himalaya.wixApi;
15
+ const verb = method.toUpperCase();
16
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
17
+ path.split("#")[0]
19
18
  );
19
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
20
+ if (!api.read)
21
+ return Promise.reject(
22
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
23
+ );
24
+ return api.read(method, path, body, wixCallHeaders(opts), {
25
+ cache: opts.cache ?? "default"
26
+ }).then((result) => {
27
+ opts.onCacheResult?.(result.cache);
28
+ return result.data;
29
+ });
30
+ }
31
+ if (opts?.cache === "only-if-cached")
32
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
33
+ return api.call(method, path, body, wixCallHeaders(opts));
20
34
  }
21
35
  function wixQueryPath(path, req) {
22
36
  const parts = [];
@@ -11,12 +11,26 @@ function wixCall(method, path, body, opts) {
11
11
  )
12
12
  );
13
13
  }
14
- return globalThis.himalaya.wixApi.call(
15
- method,
16
- path,
17
- body,
18
- wixCallHeaders(opts)
14
+ const api = globalThis.himalaya.wixApi;
15
+ const verb = method.toUpperCase();
16
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
17
+ path.split("#")[0]
19
18
  );
19
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
20
+ if (!api.read)
21
+ return Promise.reject(
22
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
23
+ );
24
+ return api.read(method, path, body, wixCallHeaders(opts), {
25
+ cache: opts.cache ?? "default"
26
+ }).then((result) => {
27
+ opts.onCacheResult?.(result.cache);
28
+ return result.data;
29
+ });
30
+ }
31
+ if (opts?.cache === "only-if-cached")
32
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
33
+ return api.call(method, path, body, wixCallHeaders(opts));
20
34
  }
21
35
  function wixQueryPath(path, req) {
22
36
  const parts = [];
@@ -1,19 +1,22 @@
1
1
  // ../../stdlib/wix-sdk/blog-v3/src/extensions.ts
2
2
  var DRAFTS = "/blog/v3/draft-posts";
3
3
  var DEFAULT_FIELDSETS = ["INTERNAL_ID", "RICH_CONTENT", "URL"];
4
- function getDraftPost(postId) {
4
+ function getDraftPost(postId, options) {
5
5
  const qs = DEFAULT_FIELDSETS.map((f) => `fieldsets=${f}`).join("&");
6
- return wixCall("GET", `${DRAFTS}/${postId}?${qs}`);
6
+ return wixCall("GET", `${DRAFTS}/${postId}?${qs}`, void 0, options);
7
7
  }
8
8
  var POST_BODY_FIELDSETS = ["RICH_CONTENT", "CONTENT_TEXT"];
9
- function getPost(postId, req = {}) {
9
+ function getPost(postId, req = {}, readOptions) {
10
10
  const fieldsets = req.fieldsets ?? POST_BODY_FIELDSETS;
11
11
  const query = fieldsets.length ? "?" + fieldsets.map((f) => `fieldsets=${encodeURIComponent(f)}`).join("&") : "";
12
12
  return wixCall(
13
13
  "GET",
14
- `/blog/v3/posts/${encodeURIComponent(postId)}` + query
14
+ `/blog/v3/posts/${encodeURIComponent(postId)}` + query,
15
+ void 0,
16
+ readOptions
15
17
  ).catch(async (cause) => {
16
- const resp = await queryPosts({ query: { filter: { id: postId } } });
18
+ if (readOptions?.cache || readOptions?.onCacheResult) throw cause;
19
+ const resp = await queryPosts({ query: { filter: { id: postId } } }, readOptions);
17
20
  const post = resp.posts?.[0];
18
21
  if (!post) {
19
22
  const err = new Error(`Blog post not found: ${postId}`);
@@ -25,8 +28,8 @@ function getPost(postId, req = {}) {
25
28
  return { post };
26
29
  });
27
30
  }
28
- function queryCategories(req = {}) {
29
- return wixCall("POST", "/blog/v3/categories/query", { query: req });
31
+ function queryCategories(req = {}, opts) {
32
+ return wixCall("POST", "/blog/v3/categories/query", { query: req }, opts);
30
33
  }
31
34
  function createDraftPost(draftPost) {
32
35
  return wixCall("POST", DRAFTS, { draftPost, fieldsets: DEFAULT_FIELDSETS });
@@ -55,8 +58,8 @@ function unlikePost(postId) {
55
58
  if (!postId) throw new Error("unlikePost: postId is required");
56
59
  return wixCall("POST", `/blog/v3/posts/${encodeURIComponent(postId)}/unlike`, {});
57
60
  }
58
- function queryDraftPosts(req = {}) {
59
- return wixCall("POST", `${DRAFTS}/query`, req);
61
+ function queryDraftPosts(req = {}, opts) {
62
+ return wixCall("POST", `${DRAFTS}/query`, req, opts);
60
63
  }
61
64
  function cancelScheduleDraftPost(postId) {
62
65
  return updateDraftPost(postId, {}, "UPDATE_CANCEL_SCHEDULE");
@@ -75,12 +78,26 @@ function wixCall(method, path, body, opts) {
75
78
  )
76
79
  );
77
80
  }
78
- return globalThis.himalaya.wixApi.call(
79
- method,
80
- path,
81
- body,
82
- wixCallHeaders(opts)
81
+ const api = globalThis.himalaya.wixApi;
82
+ const verb = method.toUpperCase();
83
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
84
+ path.split("#")[0]
83
85
  );
86
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
87
+ if (!api.read)
88
+ return Promise.reject(
89
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
90
+ );
91
+ return api.read(method, path, body, wixCallHeaders(opts), {
92
+ cache: opts.cache ?? "default"
93
+ }).then((result) => {
94
+ opts.onCacheResult?.(result.cache);
95
+ return result.data;
96
+ });
97
+ }
98
+ if (opts?.cache === "only-if-cached")
99
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
100
+ return api.call(method, path, body, wixCallHeaders(opts));
84
101
  }
85
102
  function queryPosts(req = {}, opts) {
86
103
  return wixCall(
@@ -15,8 +15,8 @@ async function searchServices(req = {}) {
15
15
  const res = await wixCall("POST", "/_api/bookings/v2/services/search", req);
16
16
  return { ...res, services: (res.services ?? []).map(decodeService) };
17
17
  }
18
- async function queryServices(req = {}) {
19
- const res = await wixCall("POST", "/bookings/v2/services/query", req);
18
+ async function queryServices(req = {}, readOptions) {
19
+ const res = await wixCall("POST", "/bookings/v2/services/query", req, readOptions);
20
20
  return { ...res, services: (res.services ?? []).map(decodeService) };
21
21
  }
22
22
  async function queryServiceCategories() {
@@ -26,7 +26,7 @@ async function queryServiceCategories() {
26
26
  async function getService(serviceId, options) {
27
27
  const path = `/bookings/v2/services/${serviceId}`;
28
28
  const conditionalFields = options?.conditionalFields ?? [];
29
- const res = await wixCall("GET", conditionalFields.length ? wixQueryPath(path, { conditionalFields }) : path);
29
+ const res = await wixCall("GET", conditionalFields.length ? wixQueryPath(path, { conditionalFields }) : path, void 0, options);
30
30
  return { ...res, service: decodeService(res.service) };
31
31
  }
32
32
  function encodeServiceWrite(write, existing) {
@@ -153,12 +153,12 @@ function rescheduleBooking(bookingId, slot, revision, notify = false) {
153
153
  flowControlSettings: { ignoreReschedulePolicy: true, ignoreBookingWindow: true, skipAvailabilityValidation: true }
154
154
  });
155
155
  }
156
- function queryServiceAvailability(serviceId, startDate, endDate, options = {}) {
156
+ function queryServiceAvailability(serviceId, startDate, endDate, options = {}, readOptions) {
157
157
  if (!serviceId) throw new Error("queryServiceAvailability: serviceId is required");
158
158
  const { bookable = true } = options ?? {};
159
159
  return wixCall("POST", "/bookings/v1/availability/query", {
160
160
  query: { filter: { serviceId: [serviceId], startDate, endDate, ...bookable ? { bookable: true } : {} } }
161
- });
161
+ }, readOptions);
162
162
  }
163
163
  function queryResources(limit = 100) {
164
164
  return wixCall("POST", "/bookings/v1/resources/query", {
@@ -192,9 +192,9 @@ function bookSchedule(scheduleId, firstName, lastName, email, options) {
192
192
  }
193
193
  });
194
194
  }
195
- function getBookingFull(bookingId) {
195
+ function getBookingFull(bookingId, options) {
196
196
  if (!bookingId) throw new Error("getBookingFull: bookingId is required");
197
- return wixCall("GET", `/bookings/v1/bookings/${bookingId}`);
197
+ return wixCall("GET", `/bookings/v1/bookings/${bookingId}`, void 0, options);
198
198
  }
199
199
  function setBookingAttendance(bookingId, attended, numberOfAttendees = 1) {
200
200
  if (!bookingId) throw new Error("setBookingAttendance: bookingId is required");
@@ -217,12 +217,26 @@ function wixCall(method, path, body, opts) {
217
217
  )
218
218
  );
219
219
  }
220
- return globalThis.himalaya.wixApi.call(
221
- method,
222
- path,
223
- body,
224
- wixCallHeaders(opts)
220
+ const api = globalThis.himalaya.wixApi;
221
+ const verb = method.toUpperCase();
222
+ const readShaped = verb === "GET" || verb === "HEAD" || verb === "POST" && /\/(query|query-cursor|search|list|count)(\?|$)/.test(
223
+ path.split("#")[0]
225
224
  );
225
+ if (readShaped && (opts?.cache || opts?.onCacheResult)) {
226
+ if (!api.read)
227
+ return Promise.reject(
228
+ new Error("READ_LIFECYCLE_UNSUPPORTED: update the Himalaya runtime")
229
+ );
230
+ return api.read(method, path, body, wixCallHeaders(opts), {
231
+ cache: opts.cache ?? "default"
232
+ }).then((result) => {
233
+ opts.onCacheResult?.(result.cache);
234
+ return result.data;
235
+ });
236
+ }
237
+ if (opts?.cache === "only-if-cached")
238
+ return Promise.reject(new Error("OFFLINE_CACHE_MISS"));
239
+ return api.call(method, path, body, wixCallHeaders(opts));
226
240
  }
227
241
  function wixQueryPath(path, req) {
228
242
  const parts = [];