@wix/himalaya-cli 0.1747.0 → 0.1749.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.
- package/bin/himi +16 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +9 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +34 -8
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +45 -18
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/l10n.mjs +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +36 -14
- package/dist/browser-plane/assets.json +7 -7
- package/dist/browser-plane/preview-deferred/{63821bbb8f637899037252154a5587f0596e4b537173c7f50551f9e44f7c22c0.bin → b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin} +1 -1
- package/dist/browser-plane/sw.js +6 -6
- package/dist/browser-plane/t5-frame.html +1 -1
- package/dist/browser-plane/t5-worker-frame.html +1 -1
- package/dist/cli.mjs +2616 -1883
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/component-reference.json +1 -1
- package/guides/component-reference.md +9 -0
- package/guides/one-app-to-himi-app.md +11 -6
- package/guides/wix-business-context.md +25 -1
- package/guides/wix-site-to-himi-app.md +2 -1
- package/package.json +2 -2
- package/template-icons/medical-services.png +0 -0
- package/templates/beauty-salon/dev/index.ts +1 -0
- package/templates/beauty-salon/l10n/en.json +6 -0
- package/templates/beauty-salon/l10n/fr.json +36 -5
- package/templates/beauty-salon/l10n/he.json +29 -4
- package/templates/beauty-salon/recipes/blog-hero.json +95 -0
- package/templates/beauty-salon/recipes/blog-list-thumb-start.json +177 -147
- package/templates/beauty-salon/recipes/blog-list.json +172 -142
- package/templates/beauty-salon/recipes/events-inline-list.json +30 -5
- package/templates/beauty-salon/recipes/events-inline.json +30 -5
- package/templates/beauty-salon/recipes/faq-list.json +503 -0
- package/templates/beauty-salon/recipes/groups-list.json +196 -0
- package/templates/beauty-salon/recipes/products-carousel.json +141 -0
- package/templates/beauty-salon/recipes/products-grid.json +143 -0
- package/templates/beauty-salon/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/beauty-salon/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/beauty-salon/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/beauty-salon/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/beauty-salon/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/beauty-salon/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/beauty-salon/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/beauty-salon/tier5-src/_shared/products-section.ts +76 -0
- package/templates/beauty-salon/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/beauty-salon/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +6 -2
- package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +7 -2
- package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +6 -4
- package/templates/beauty-salon-owner/dev/index.ts +54 -0
- package/templates/beauty-salon-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/branded-lite/dev/index.ts +1 -0
- package/templates/branded-lite/l10n/fr.json +15 -5
- package/templates/branded-lite/l10n/he.json +12 -4
- package/templates/branded-lite/recipes/blog-hero.json +95 -0
- package/templates/branded-lite/recipes/blog-list-thumb-start.json +177 -147
- package/templates/branded-lite/recipes/blog-list.json +172 -142
- package/templates/branded-lite/recipes/events-inline-list.json +30 -5
- package/templates/branded-lite/recipes/events-inline.json +30 -5
- package/templates/branded-lite/recipes/faq-list.json +503 -0
- package/templates/branded-lite/recipes/groups-list.json +196 -0
- package/templates/branded-lite/recipes/products-carousel.json +141 -0
- package/templates/branded-lite/recipes/products-grid.json +143 -0
- package/templates/branded-lite/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/branded-lite/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/branded-lite/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/branded-lite/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/branded-lite/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/branded-lite/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/branded-lite/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/branded-lite/tier5-src/_shared/products-section.ts +76 -0
- package/templates/branded-lite/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/branded-lite/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +6 -2
- package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +7 -2
- package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +6 -4
- package/templates/branded-lite/tier5-src/himi-branded-lite-faq/index.ts +5 -369
- package/templates/brandy/README.md +46 -5
- package/templates/brandy/config.ts +11 -0
- package/templates/brandy/himalaya.template.json +1 -1
- package/templates/community-club/dev/index.ts +1 -0
- package/templates/community-club/l10n/fr.json +25 -5
- package/templates/community-club/l10n/he.json +20 -4
- package/templates/community-club/recipes/blog-hero.json +95 -0
- package/templates/community-club/recipes/blog-list-thumb-start.json +177 -147
- package/templates/community-club/recipes/blog-list.json +172 -142
- package/templates/community-club/recipes/events-inline-list.json +30 -5
- package/templates/community-club/recipes/events-inline.json +30 -5
- package/templates/community-club/recipes/faq-list.json +503 -0
- package/templates/community-club/recipes/groups-list.json +196 -0
- package/templates/community-club/recipes/products-carousel.json +141 -0
- package/templates/community-club/recipes/products-grid.json +143 -0
- package/templates/community-club/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/community-club/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/community-club/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/community-club/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/community-club/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/community-club/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/community-club/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/community-club/tier5-src/_shared/products-section.ts +76 -0
- package/templates/community-club/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/community-club-owner/dev/index.ts +54 -0
- package/templates/community-club-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/community-club-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/conference/dev/index.ts +1 -0
- package/templates/events-meetups/dev/index.ts +1 -0
- package/templates/events-meetups/l10n/fr.json +25 -5
- package/templates/events-meetups/l10n/he.json +20 -4
- package/templates/events-meetups/recipes/blog-hero.json +95 -0
- package/templates/events-meetups/recipes/blog-list-thumb-start.json +177 -147
- package/templates/events-meetups/recipes/blog-list.json +172 -142
- package/templates/events-meetups/recipes/events-inline-list.json +30 -5
- package/templates/events-meetups/recipes/events-inline.json +30 -5
- package/templates/events-meetups/recipes/faq-list.json +503 -0
- package/templates/events-meetups/recipes/groups-list.json +196 -0
- package/templates/events-meetups/recipes/products-carousel.json +141 -0
- package/templates/events-meetups/recipes/products-grid.json +143 -0
- package/templates/events-meetups/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/events-meetups/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/events-meetups/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/events-meetups/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/events-meetups/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/events-meetups/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/events-meetups/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/events-meetups/tier5-src/_shared/products-section.ts +76 -0
- package/templates/events-meetups/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/events-meetups-owner/dev/index.ts +54 -0
- package/templates/events-meetups-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/events-meetups-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/gym-fitness/dev/index.ts +1 -0
- package/templates/gym-fitness/l10n/en.json +6 -0
- package/templates/gym-fitness/l10n/fr.json +36 -5
- package/templates/gym-fitness/l10n/he.json +29 -4
- package/templates/gym-fitness/recipes/blog-hero.json +95 -0
- package/templates/gym-fitness/recipes/blog-list-thumb-start.json +177 -147
- package/templates/gym-fitness/recipes/blog-list.json +172 -142
- package/templates/gym-fitness/recipes/events-inline-list.json +30 -5
- package/templates/gym-fitness/recipes/events-inline.json +30 -5
- package/templates/gym-fitness/recipes/faq-list.json +503 -0
- package/templates/gym-fitness/recipes/groups-list.json +196 -0
- package/templates/gym-fitness/recipes/products-carousel.json +141 -0
- package/templates/gym-fitness/recipes/products-grid.json +143 -0
- package/templates/gym-fitness/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/gym-fitness/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/gym-fitness/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/gym-fitness/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/gym-fitness/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/gym-fitness/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/gym-fitness/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/gym-fitness/tier5-src/_shared/products-section.ts +76 -0
- package/templates/gym-fitness/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/gym-fitness/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +6 -2
- package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +7 -2
- package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +6 -4
- package/templates/gym-fitness-owner/dev/index.ts +54 -0
- package/templates/gym-fitness-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/medical-services/README.md +53 -0
- package/templates/medical-services/config.ts +320 -0
- package/templates/medical-services/dev/index.ts +17783 -0
- package/templates/medical-services/himalaya.content.json +46 -0
- package/templates/medical-services/himalaya.template.json +14 -0
- package/templates/medical-services/icon.png +0 -0
- package/templates/medical-services/platforms.json +1 -0
- package/templates/medical-services/tier5-src/_shared/app-locale.ts +61 -0
- package/templates/medical-services/tier5-src/_shared/booking-location.ts +147 -0
- package/templates/medical-services/tier5-src/_shared/booking-session.ts +222 -0
- package/templates/medical-services/tier5-src/_shared/branded-lite-hosted.ts +280 -0
- package/templates/medical-services/tier5-src/_shared/branded-load-state.ts +109 -0
- package/templates/medical-services/tier5-src/_shared/business-chat-copy.ts +40 -0
- package/templates/medical-services/tier5-src/_shared/business-chat-history.ts +51 -0
- package/templates/medical-services/tier5-src/_shared/business-chat-message-model.ts +177 -0
- package/templates/medical-services/tier5-src/_shared/business-chat-model.ts +56 -0
- package/templates/medical-services/tier5-src/_shared/business-chat-presenter.ts +576 -0
- package/templates/medical-services/tier5-src/_shared/business-chat-transport.ts +148 -0
- package/templates/medical-services/tier5-src/_shared/collection-contract.ts +228 -0
- package/templates/medical-services/tier5-src/_shared/collection-query.ts +193 -0
- package/templates/medical-services/tier5-src/_shared/collection-service.ts +400 -0
- package/templates/medical-services/tier5-src/_shared/engine-intl.ts +523 -0
- package/templates/medical-services/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/medical-services/tier5-src/_shared/himi-account.ts +194 -0
- package/templates/medical-services/tier5-src/_shared/himi-booking-saved.ts +88 -0
- package/templates/medical-services/tier5-src/_shared/himi-bookings.ts +318 -0
- package/templates/medical-services/tier5-src/_shared/himi-copy.ts +116 -0
- package/templates/medical-services/tier5-src/_shared/himi-store.ts +7 -0
- package/templates/medical-services/tier5-src/_shared/himi-text.ts +24 -0
- package/templates/medical-services/tier5-src/_shared/host-events.ts +66 -0
- package/templates/medical-services/tier5-src/_shared/hosted-checkout.ts +70 -0
- package/templates/medical-services/tier5-src/_shared/iap-attendance-form.ts +106 -0
- package/templates/medical-services/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
- package/templates/medical-services/tier5-src/_shared/iap-attendance.ts +38 -0
- package/templates/medical-services/tier5-src/_shared/iap-worker.ts +127 -0
- package/templates/medical-services/tier5-src/_shared/inbox-rooms.ts +68 -0
- package/templates/medical-services/tier5-src/_shared/local-preferences.ts +38 -0
- package/templates/medical-services/tier5-src/_shared/member-access.ts +52 -0
- package/templates/medical-services/tier5-src/_shared/member-account-routes.ts +52 -0
- package/templates/medical-services/tier5-src/_shared/member-bookings.ts +107 -0
- package/templates/medical-services/tier5-src/_shared/member-screen.ts +99 -0
- package/templates/medical-services/tier5-src/_shared/notification-target.ts +141 -0
- package/templates/medical-services/tier5-src/_shared/offset-page.ts +10 -0
- package/templates/medical-services/tier5-src/_shared/online-actions.ts +76 -0
- package/templates/medical-services/tier5-src/_shared/owner-load-error.ts +348 -0
- package/templates/medical-services/tier5-src/_shared/payment-setup.ts +6 -0
- package/templates/medical-services/tier5-src/_shared/rich-body.ts +78 -0
- package/templates/medical-services/tier5-src/_shared/rich-content-link.ts +34 -0
- package/templates/medical-services/tier5-src/_shared/sign-in-sheet.ts +18 -0
- package/templates/medical-services/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/medical-services/tier5-src/_shared/weekly-goal.ts +107 -0
- package/templates/medical-services/tier5-src/_shared/wix-bi.ts +85 -0
- package/templates/medical-services/tier5-src/_shared/wix-member-links.ts +114 -0
- package/templates/medical-services/tier5-src/_shared/wix-service-price.ts +146 -0
- package/templates/medical-services/tier5-src/business-chat/index.ts +732 -0
- package/templates/medical-services/tier5-src/himi-booking-account/index.ts +252 -0
- package/templates/medical-services/tier5-src/himi-booking-bookings/index.ts +468 -0
- package/templates/medical-services/tier5-src/himi-booking-service/index.ts +1190 -0
- package/templates/medical-services/tier5-src/himi-booking-services/index.ts +791 -0
- package/templates/medical-services/tier5-src/himi-booking-time/index.ts +1729 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-faq/index.ts +6 -0
- package/templates/medical-services/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
- package/templates/medical-services/tier5-src/himi-clinic-home/index.ts +389 -0
- package/templates/medical-services/tier5-src/himi-store-account/index.ts +998 -0
- package/templates/medical-services/tokens.json +418 -0
- package/templates/nonprofit-cause/dev/index.ts +1 -0
- package/templates/nonprofit-cause/l10n/fr.json +25 -5
- package/templates/nonprofit-cause/l10n/he.json +20 -4
- package/templates/nonprofit-cause/recipes/blog-hero.json +95 -0
- package/templates/nonprofit-cause/recipes/blog-list-thumb-start.json +177 -147
- package/templates/nonprofit-cause/recipes/blog-list.json +172 -142
- package/templates/nonprofit-cause/recipes/events-inline-list.json +30 -5
- package/templates/nonprofit-cause/recipes/events-inline.json +30 -5
- package/templates/nonprofit-cause/recipes/faq-list.json +503 -0
- package/templates/nonprofit-cause/recipes/groups-list.json +196 -0
- package/templates/nonprofit-cause/recipes/products-carousel.json +141 -0
- package/templates/nonprofit-cause/recipes/products-grid.json +143 -0
- package/templates/nonprofit-cause/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/nonprofit-cause/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/nonprofit-cause/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/nonprofit-cause/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/nonprofit-cause/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/nonprofit-cause/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/nonprofit-cause/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/nonprofit-cause/tier5-src/_shared/products-section.ts +76 -0
- package/templates/nonprofit-cause/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/nonprofit-cause-owner/dev/index.ts +54 -0
- package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/owner-lite/dev/index.ts +54 -0
- package/templates/owner-lite/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/owner-lite/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/podcast-creator/dev/index.ts +1 -0
- package/templates/podcast-creator/l10n/fr.json +35 -5
- package/templates/podcast-creator/l10n/he.json +28 -4
- package/templates/podcast-creator/recipes/blog-hero.json +95 -0
- package/templates/podcast-creator/recipes/blog-list-thumb-start.json +177 -147
- package/templates/podcast-creator/recipes/blog-list.json +172 -142
- package/templates/podcast-creator/recipes/events-inline-list.json +30 -5
- package/templates/podcast-creator/recipes/events-inline.json +30 -5
- package/templates/podcast-creator/recipes/faq-list.json +503 -0
- package/templates/podcast-creator/recipes/groups-list.json +196 -0
- package/templates/podcast-creator/recipes/products-carousel.json +141 -0
- package/templates/podcast-creator/recipes/products-grid.json +143 -0
- package/templates/podcast-creator/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/podcast-creator/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/podcast-creator/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/podcast-creator/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/podcast-creator/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/podcast-creator/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/podcast-creator/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/podcast-creator/tier5-src/_shared/products-section.ts +76 -0
- package/templates/podcast-creator/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/podcast-creator-owner/dev/index.ts +54 -0
- package/templates/podcast-creator-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/portfolio-creative/dev/index.ts +1 -0
- package/templates/portfolio-creative/l10n/fr.json +25 -5
- package/templates/portfolio-creative/l10n/he.json +20 -4
- package/templates/portfolio-creative/recipes/blog-hero.json +95 -0
- package/templates/portfolio-creative/recipes/blog-list-thumb-start.json +177 -147
- package/templates/portfolio-creative/recipes/blog-list.json +172 -142
- package/templates/portfolio-creative/recipes/events-inline-list.json +30 -5
- package/templates/portfolio-creative/recipes/events-inline.json +30 -5
- package/templates/portfolio-creative/recipes/faq-list.json +503 -0
- package/templates/portfolio-creative/recipes/groups-list.json +196 -0
- package/templates/portfolio-creative/recipes/products-carousel.json +141 -0
- package/templates/portfolio-creative/recipes/products-grid.json +143 -0
- package/templates/portfolio-creative/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/portfolio-creative/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/portfolio-creative/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/portfolio-creative/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/portfolio-creative/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/portfolio-creative/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/portfolio-creative/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/portfolio-creative/tier5-src/_shared/products-section.ts +76 -0
- package/templates/portfolio-creative/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/portfolio-creative-owner/dev/index.ts +54 -0
- package/templates/portfolio-creative-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/restaurant/dev/index.ts +1 -0
- package/templates/restaurant/l10n/fr.json +35 -5
- package/templates/restaurant/l10n/he.json +28 -4
- package/templates/restaurant/recipes/blog-hero.json +95 -0
- package/templates/restaurant/recipes/blog-list-thumb-start.json +177 -147
- package/templates/restaurant/recipes/blog-list.json +172 -142
- package/templates/restaurant/recipes/events-inline-list.json +30 -5
- package/templates/restaurant/recipes/events-inline.json +30 -5
- package/templates/restaurant/recipes/faq-list.json +503 -0
- package/templates/restaurant/recipes/groups-list.json +196 -0
- package/templates/restaurant/recipes/products-carousel.json +141 -0
- package/templates/restaurant/recipes/products-grid.json +143 -0
- package/templates/restaurant/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/restaurant/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/restaurant/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/restaurant/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/restaurant/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/restaurant/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/restaurant/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/restaurant/tier5-src/_shared/products-section.ts +76 -0
- package/templates/restaurant/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/restaurant-owner/dev/index.ts +54 -0
- package/templates/restaurant-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/restaurant-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/retail-store/dev/index.ts +1 -0
- package/templates/retail-store/l10n/fr.json +25 -5
- package/templates/retail-store/l10n/he.json +20 -4
- package/templates/retail-store/recipes/blog-hero.json +95 -0
- package/templates/retail-store/recipes/blog-list-thumb-start.json +177 -147
- package/templates/retail-store/recipes/blog-list.json +172 -142
- package/templates/retail-store/recipes/events-inline-list.json +30 -5
- package/templates/retail-store/recipes/events-inline.json +30 -5
- package/templates/retail-store/recipes/faq-list.json +503 -0
- package/templates/retail-store/recipes/groups-list.json +196 -0
- package/templates/retail-store/recipes/products-carousel.json +141 -0
- package/templates/retail-store/recipes/products-grid.json +143 -0
- package/templates/retail-store/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/retail-store/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/retail-store/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/retail-store/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/retail-store/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/retail-store/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/retail-store/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/retail-store/tier5-src/_shared/products-section.ts +76 -0
- package/templates/retail-store/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/retail-store-owner/dev/index.ts +54 -0
- package/templates/retail-store-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/retail-store-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
- package/templates/salon-spa/dev/index.ts +1 -0
- package/templates/salon-spa/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/salon-spa/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +6 -2
- package/templates/salon-spa/tier5-src/himi-booking-service/index.ts +7 -2
- package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +6 -4
- package/templates/wholesale-store/dev/index.ts +1 -0
- package/templates/yoga-studio/dev/index.ts +1 -0
- package/templates/yoga-studio/l10n/en.json +6 -0
- package/templates/yoga-studio/l10n/fr.json +46 -5
- package/templates/yoga-studio/l10n/he.json +37 -4
- package/templates/yoga-studio/recipes/blog-hero.json +95 -0
- package/templates/yoga-studio/recipes/blog-list-thumb-start.json +177 -147
- package/templates/yoga-studio/recipes/blog-list.json +172 -142
- package/templates/yoga-studio/recipes/events-inline-list.json +30 -5
- package/templates/yoga-studio/recipes/events-inline.json +30 -5
- package/templates/yoga-studio/recipes/faq-list.json +503 -0
- package/templates/yoga-studio/recipes/groups-list.json +196 -0
- package/templates/yoga-studio/recipes/products-carousel.json +141 -0
- package/templates/yoga-studio/recipes/products-grid.json +143 -0
- package/templates/yoga-studio/tier5-src/_shared/blog-list.ts +9 -9
- package/templates/yoga-studio/tier5-src/_shared/events-inline.ts +7 -5
- package/templates/yoga-studio/tier5-src/_shared/faq-list.ts +405 -0
- package/templates/yoga-studio/tier5-src/_shared/groups-section.ts +110 -0
- package/templates/yoga-studio/tier5-src/_shared/member-bookings.ts +17 -4
- package/templates/yoga-studio/tier5-src/_shared/member-row-extras.ts +10 -2
- package/templates/yoga-studio/tier5-src/_shared/members-directory.ts +9 -5
- package/templates/yoga-studio/tier5-src/_shared/products-section.ts +76 -0
- package/templates/yoga-studio/tier5-src/_shared/programs-section.ts +2 -2
- package/templates/yoga-studio/tier5-src/_shared/staff-name.ts +18 -0
- package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +6 -2
- package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +7 -2
- package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +6 -4
- package/templates/yoga-studio-owner/dev/index.ts +54 -0
- package/templates/yoga-studio-owner/tier5-src/_shared/aria-chat.ts +30 -4
- package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// Shared Wix Bookings shaping for himi workers (branded-lite `bookings`
|
|
2
|
+
// vertical): defensive extraction where the LIVE services payload drifts from
|
|
3
|
+
// the generated client's types. Used by BOTH the services-list worker
|
|
4
|
+
// (himi_services rows) and the service-detail worker so the two screens agree
|
|
5
|
+
// on one shape (the himi-restaurants.ts pattern).
|
|
6
|
+
|
|
7
|
+
/** Human-readable category name. The live services payload carries `category`
|
|
8
|
+
* as a STRUCTURED object (`{ id, name, sortOrder }`) while the generated
|
|
9
|
+
* client types it as a string — joined raw it rendered
|
|
10
|
+
* "[object Object] · 1 hr · $111" in the services rows (production sweep R3).
|
|
11
|
+
* Extract the name member; an id-only/unrecognizable shape yields "" so the
|
|
12
|
+
* caller omits the segment instead of stringifying the object. */
|
|
13
|
+
export function categoryName(value: unknown): string {
|
|
14
|
+
if (typeof value === "string") return value.trim();
|
|
15
|
+
if (!value || typeof value !== "object") return "";
|
|
16
|
+
const name = (value as { name?: unknown }).name;
|
|
17
|
+
return typeof name === "string" ? name.trim() : "";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
import { businessTimeZone } from "./app-locale.js";
|
|
21
|
+
import { formatDateMedium, formatMonthDay, zoneOffsetAt } from "./engine-intl.js";
|
|
22
|
+
import { formatServiceMoney, formatServicePrice, serviceCurrency } from "./wix-service-price.js";
|
|
23
|
+
|
|
24
|
+
const HAS_OFFSET = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
25
|
+
const LOCAL_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}))?/;
|
|
26
|
+
|
|
27
|
+
/** The instant (ms) a slot starts. Wix may list a slot's `startDate` as a LOCAL wall time with its
|
|
28
|
+
* `timezone` beside it ("2026-11-02T18:30:00" in America/New_York is 23:30Z); a bare `Date.parse`
|
|
29
|
+
* would read that in the device's zone. So a local time is placed in the slot's own zone when this
|
|
30
|
+
* engine has Intl and knows the zone, and read in the device's zone only when it cannot be. */
|
|
31
|
+
export function slotStartInstant(slot: { startDate?: string; timezone?: unknown }): number {
|
|
32
|
+
const start = slot.startDate ?? "";
|
|
33
|
+
if (!start) return NaN;
|
|
34
|
+
const local = LOCAL_TIME.exec(start);
|
|
35
|
+
if (HAS_OFFSET.test(start) || !local || typeof slot.timezone !== "string" || !slot.timezone) return Date.parse(start);
|
|
36
|
+
const wall = Date.UTC(+local[1], +local[2] - 1, +local[3], +local[4], +local[5], +(local[6] ?? 0));
|
|
37
|
+
const offset = zoneOffsetAt(wall, slot.timezone);
|
|
38
|
+
if (!Number.isFinite(offset)) return Date.parse(start);
|
|
39
|
+
// Once more at the corrected instant, so a wall time beside a DST change lands on the right side.
|
|
40
|
+
const again = zoneOffsetAt(wall - offset, slot.timezone);
|
|
41
|
+
return wall - (Number.isFinite(again) ? again : offset);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `himi_time` reads the next two weeks. A host's `start` past them (an Agenda session weeks
|
|
45
|
+
* ahead) is read on its own — that session's local day only, never everything up to it — so it
|
|
46
|
+
* can be preselected while each read stays bounded. `undefined` when the start is inside the two
|
|
47
|
+
* weeks. */
|
|
48
|
+
export function availabilityBeyond(now: Date, start = ""): { from: Date; until: Date } | undefined {
|
|
49
|
+
const end = now.getTime() + 14 * 86_400_000;
|
|
50
|
+
const at = start ? Date.parse(start) : NaN;
|
|
51
|
+
if (!Number.isFinite(at) || at < end) return undefined;
|
|
52
|
+
const d = new Date(at);
|
|
53
|
+
const dayStart = new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
54
|
+
// Never back into the two weeks already read: a slot in both would be listed twice.
|
|
55
|
+
return { from: new Date(Math.max(dayStart.getTime(), end)), until: new Date(d.getFullYear(), d.getMonth(), d.getDate() + 1) };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The slot a host asked to open at (`himi_time` input `start`, an ISO 8601 instant): the id of the
|
|
59
|
+
* slot that starts at that same instant, or "" when none does (taken since, or out of the window).
|
|
60
|
+
* Compared as instants, so `…T16:30:00Z` finds a slot listed as `…T18:30:00+02:00`, or as a local
|
|
61
|
+
* `…T18:30:00` beside `timezone: "Asia/Jerusalem"`. */
|
|
62
|
+
export function slotIdAt(slots: Iterable<[string, { startDate?: string; timezone?: unknown }]>, start: string): string {
|
|
63
|
+
const at = start ? Date.parse(start) : NaN;
|
|
64
|
+
if (!Number.isFinite(at)) return "";
|
|
65
|
+
for (const [id, slot] of slots) {
|
|
66
|
+
if (slotStartInstant(slot) === at) return id;
|
|
67
|
+
}
|
|
68
|
+
return "";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ---- Courses ----------------------------------------------------------------------
|
|
72
|
+
// One answer for the service screen's course button and the time screen's course booking, so
|
|
73
|
+
// the button never offers a course that the booking step then refuses.
|
|
74
|
+
|
|
75
|
+
type CoursePolicyShape = {
|
|
76
|
+
/** `timeZone`: the business's IANA zone, for a session time Wix lists as a bare local wall time. */
|
|
77
|
+
schedule?: { id?: string; firstSessionStart?: string; lastSessionEnd?: string; timeZone?: string };
|
|
78
|
+
bookingPolicy?: {
|
|
79
|
+
bookAfterStartPolicy?: { enabled?: boolean };
|
|
80
|
+
limitEarlyBookingPolicy?: { enabled?: boolean; earliestBookingInMinutes?: number };
|
|
81
|
+
limitLateBookingPolicy?: { enabled?: boolean; latestBookingInMinutes?: number };
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** A bare local wall time placed in `timeZone`, as an instant (ms). NaN when the value is not a bare local
|
|
86
|
+
* time, has an impossible calendar day, or the engine does not know the zone. */
|
|
87
|
+
function placedInstant(value: string, timeZone: string | undefined): number {
|
|
88
|
+
const local = LOCAL_TIME.exec(value);
|
|
89
|
+
if (HAS_OFFSET.test(value) || !local || !timeZone || !validDate(value)) return NaN;
|
|
90
|
+
const wall = Date.UTC(+local[1], +local[2] - 1, +local[3], +local[4], +local[5], +(local[6] ?? 0));
|
|
91
|
+
const offset = zoneOffsetAt(wall, timeZone);
|
|
92
|
+
if (!Number.isFinite(offset)) return NaN;
|
|
93
|
+
// Once more at the corrected instant, so a wall time beside a DST change lands on the right side.
|
|
94
|
+
const again = zoneOffsetAt(wall - offset, timeZone);
|
|
95
|
+
return wall - (Number.isFinite(again) ? again : offset);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** The zone that places a course's bare local session times: the schedule's own, else the app's
|
|
99
|
+
* provisioned business zone. "" when there is none: a zone is never guessed. */
|
|
100
|
+
const courseZone = (schedule: { timeZone?: string } | undefined): string => schedule?.timeZone || businessTimeZone();
|
|
101
|
+
|
|
102
|
+
/** The instant (ms) of a course session time, for the "Ended" label. A time with an offset is exact. A
|
|
103
|
+
* bare local wall time is the BUSINESS's wall time, so it is placed in its zone — never in the device's,
|
|
104
|
+
* which would present another zone's clock as a confirmed instant. No zone, a date-only value, an
|
|
105
|
+
* impossible calendar day or an engine that does not know the zone: unknown (NaN). */
|
|
106
|
+
function sessionInstant(value: string, timeZone: string | undefined): number {
|
|
107
|
+
return HAS_OFFSET.test(value) ? validDate(value)?.getTime() ?? NaN : placedInstant(value, timeZone);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The same instant for the booking rules (window, read range): a bare local time the business zone can
|
|
111
|
+
* place is placed there, so the list label, the service screen and the time screen agree. Everything else
|
|
112
|
+
* keeps the read they always had (`Date.parse`), so an app with no provisioned zone is unchanged. */
|
|
113
|
+
function courseInstant(value: string | undefined, timeZone: string | undefined): number {
|
|
114
|
+
const text = value ?? "";
|
|
115
|
+
const placed = placedInstant(text, timeZone);
|
|
116
|
+
return Number.isFinite(placed) ? placed : Date.parse(text);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** A completed course, independent of whether bookings are currently allowed. Missing,
|
|
120
|
+
* invalid or reversed dates are unknown, never evidence that a course has ended. A session time
|
|
121
|
+
* without an offset counts only when the schedule names the business's `timeZone`. */
|
|
122
|
+
export function courseHasEnded(service: CoursePolicyShape, now: number): boolean {
|
|
123
|
+
const zone = courseZone(service.schedule);
|
|
124
|
+
const first = sessionInstant(service.schedule?.firstSessionStart ?? "", zone);
|
|
125
|
+
const last = sessionInstant(service.schedule?.lastSessionEnd ?? "", zone);
|
|
126
|
+
return Number.isFinite(now) && Number.isFinite(first) && Number.isFinite(last) && first <= last && last <= now;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Does this course schedule hold a session time that is a bare local wall time, which only the
|
|
130
|
+
* business's zone can place? A caller reads the zone only when this is true. */
|
|
131
|
+
export function courseNeedsZone(schedule: { firstSessionStart?: string; lastSessionEnd?: string } | undefined): boolean {
|
|
132
|
+
return [schedule?.firstSessionStart, schedule?.lastSessionEnd].some((value) => !!value && !HAS_OFFSET.test(value) && LOCAL_TIME.test(value));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Whether the business takes course bookings at `now` (ms): the course has not ended, has not
|
|
136
|
+
* started (unless the policy lets people join late), and `now` is inside its booking window —
|
|
137
|
+
* which the early and late limits count from the first session. */
|
|
138
|
+
export function courseWindowOpen(service: CoursePolicyShape, now: number): boolean {
|
|
139
|
+
const zone = courseZone(service.schedule);
|
|
140
|
+
const first = courseInstant(service.schedule?.firstSessionStart, zone);
|
|
141
|
+
const last = courseInstant(service.schedule?.lastSessionEnd, zone);
|
|
142
|
+
if (!Number.isFinite(first) || !Number.isFinite(last) || last <= now) return false;
|
|
143
|
+
const policy = service.bookingPolicy;
|
|
144
|
+
if (first < now && policy?.bookAfterStartPolicy?.enabled !== true) return false;
|
|
145
|
+
const early = policy?.limitEarlyBookingPolicy;
|
|
146
|
+
if (early?.enabled && typeof early.earliestBookingInMinutes === "number" && now < first - early.earliestBookingInMinutes * 60_000) return false;
|
|
147
|
+
const late = policy?.limitLateBookingPolicy;
|
|
148
|
+
if (late?.enabled && typeof late.latestBookingInMinutes === "number" && now > first - late.latestBookingInMinutes * 60_000) return false;
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** How far ahead a course is read: the whole remaining course, up to a year. Both screens read the
|
|
153
|
+
* same sessions — from the later of its first session and now — so the service screen never
|
|
154
|
+
* offers a course that the booking step then refuses on a session the first did not read. */
|
|
155
|
+
export const COURSE_READ_DAYS = 366;
|
|
156
|
+
const DAY = 86_400_000;
|
|
157
|
+
|
|
158
|
+
/** The 14-day availability windows covering a course's remaining sessions, and whether they reach
|
|
159
|
+
* its last session (`complete`) and start at its first (`fromFirst`, so a count is the whole
|
|
160
|
+
* course). Empty when the course has no usable dates or has ended. */
|
|
161
|
+
export function courseReadWindows(service: CoursePolicyShape, now: number, chunkDays = 14): { windows: Array<[number, number]>; complete: boolean; fromFirst: boolean } {
|
|
162
|
+
const zone = courseZone(service.schedule);
|
|
163
|
+
const first = courseInstant(service.schedule?.firstSessionStart, zone);
|
|
164
|
+
const last = courseInstant(service.schedule?.lastSessionEnd, zone);
|
|
165
|
+
if (!Number.isFinite(first) || !Number.isFinite(last)) return { windows: [], complete: false, fromFirst: false };
|
|
166
|
+
const from = Math.max(first, now);
|
|
167
|
+
const courseEnd = last + DAY;
|
|
168
|
+
const until = Math.min(courseEnd, from + COURSE_READ_DAYS * DAY);
|
|
169
|
+
const windows: Array<[number, number]> = [];
|
|
170
|
+
for (let at = from; at < until; at += chunkDays * DAY) windows.push([at, Math.min(until, at + chunkDays * DAY)]);
|
|
171
|
+
return { windows, complete: courseEnd <= until, fromFirst: from === first };
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
type CourseEntryShape = { slot?: { startDate?: string; timezone?: unknown }; bookable?: boolean; openSpots?: number };
|
|
175
|
+
|
|
176
|
+
/** A course across EVERY upcoming session read: a customer books all of them at once, so the
|
|
177
|
+
* smallest open count is the course's, and one session that cannot be booked closes it. A start
|
|
178
|
+
* is read in the session's own zone (`slotStartInstant`). `found` is false when no upcoming
|
|
179
|
+
* session came back: both screens then treat the course as not bookable. So is a course whose
|
|
180
|
+
* read did not reach its last session (`readComplete`, from `courseReadWindows`): a session
|
|
181
|
+
* past the year read may be full, and the course is booked whole. */
|
|
182
|
+
export function courseSessionsAvailability(entries: readonly CourseEntryShape[], now: number, readComplete = true): { found: boolean; spots: number | undefined; bookable: boolean } {
|
|
183
|
+
const upcoming = entries.filter((entry) => {
|
|
184
|
+
const start = entry.slot ? slotStartInstant(entry.slot as { startDate?: string; timezone?: unknown }) : NaN;
|
|
185
|
+
return Number.isFinite(start) && start >= now;
|
|
186
|
+
});
|
|
187
|
+
if (!upcoming.length) return { found: false, spots: undefined, bookable: false };
|
|
188
|
+
const counts = upcoming.map((entry) => entry.openSpots).filter((n): n is number => typeof n === "number" && Number.isFinite(n) && n >= 0);
|
|
189
|
+
const spots = counts.length ? Math.min(...counts) : undefined;
|
|
190
|
+
return { found: true, spots, bookable: readComplete && upcoming.every((entry) => entry.bookable !== false) && spots !== 0 };
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ---- Price, duration and course dates ------------------------------------------------
|
|
194
|
+
// One answer for the services list and the service screen, so a row and the screen it opens
|
|
195
|
+
// say the same price and the same length. Each screen reads its own copy keys: the caller
|
|
196
|
+
// passes a `BookingLabel` reader bound to its prefix ("service." on the service screen,
|
|
197
|
+
// "services." on the list).
|
|
198
|
+
|
|
199
|
+
/** Reads one copy line by its key suffix ("priceFree", "days"). `values` fills {placeholders}. */
|
|
200
|
+
export type BookingLabel = (key: string, fallback: string, values?: Record<string, string | number>) => string;
|
|
201
|
+
|
|
202
|
+
type PricedServiceShape = {
|
|
203
|
+
type?: string;
|
|
204
|
+
duration?: unknown;
|
|
205
|
+
payment?: {
|
|
206
|
+
rateType?: unknown;
|
|
207
|
+
fixed?: { price?: unknown };
|
|
208
|
+
varied?: { minPrice?: unknown; defaultPrice?: unknown };
|
|
209
|
+
custom?: { description?: unknown };
|
|
210
|
+
};
|
|
211
|
+
schedule?: {
|
|
212
|
+
firstSessionStart?: string;
|
|
213
|
+
lastSessionEnd?: string;
|
|
214
|
+
availabilityConstraints?: {
|
|
215
|
+
sessionDurations?: unknown[];
|
|
216
|
+
durations?: Array<{ minutes?: unknown } | undefined>;
|
|
217
|
+
durationRange?: {
|
|
218
|
+
hourOptions?: { minDurationInMinutes?: unknown; maxDurationInMinutes?: unknown };
|
|
219
|
+
dayOptions?: { minDurationInDays?: unknown; maxDurationInDays?: unknown };
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
function trimmed(value: unknown): string {
|
|
226
|
+
return typeof value === "string" ? value.trim() : "";
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function finiteNumber(value: unknown): number | undefined {
|
|
230
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : undefined;
|
|
231
|
+
if (typeof value === "string" && value.trim()) {
|
|
232
|
+
const n = Number(value);
|
|
233
|
+
return Number.isNaN(n) ? undefined : n;
|
|
234
|
+
}
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface ServicePriceLine { text: string; unit: string; isText: boolean }
|
|
239
|
+
|
|
240
|
+
/** The price line by rate type. FIXED → the price, no cents on a whole amount; VARIED →
|
|
241
|
+
* "From {price}"; CUSTOM → the owner's description, no unit; NO_FEE → "Free", no unit. */
|
|
242
|
+
export function servicePriceLine(service: PricedServiceShape, label: BookingLabel): ServicePriceLine {
|
|
243
|
+
const payment = service.payment ?? {};
|
|
244
|
+
const rate = trimmed(payment.rateType).toUpperCase();
|
|
245
|
+
const currency = serviceCurrency(service);
|
|
246
|
+
const unit = service.type === "COURSE"
|
|
247
|
+
? label("unitParticipant", "per participant")
|
|
248
|
+
: label("unitSession", "per session");
|
|
249
|
+
if (rate === "NO_FEE") return { text: label("priceFree", "Free"), unit: "", isText: false };
|
|
250
|
+
if (rate === "CUSTOM") return { text: trimmed(payment.custom?.description), unit: "", isText: true };
|
|
251
|
+
if (rate === "VARIED") {
|
|
252
|
+
const from = formatServiceMoney(payment.varied?.minPrice, currency) || formatServiceMoney(payment.varied?.defaultPrice, currency);
|
|
253
|
+
return { text: from ? label("priceFrom", "From {price}", { price: from }) : "", unit: from ? unit : "", isText: false };
|
|
254
|
+
}
|
|
255
|
+
// FIXED, or a legacy payload with no rate type.
|
|
256
|
+
const text = formatServiceMoney(payment.fixed?.price, currency) || formatServicePrice(service);
|
|
257
|
+
return { text, unit: text ? unit : "", isText: false };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function minutesText(minutes: number): string {
|
|
261
|
+
if (minutes < 60) return `${minutes} min`;
|
|
262
|
+
const hours = Math.floor(minutes / 60);
|
|
263
|
+
const rest = minutes % 60;
|
|
264
|
+
return rest ? `${hours} hr ${rest} min` : `${hours} hr`;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** "45 min", "1 hr 30 min"; a service with several lengths, or a flexible range the
|
|
268
|
+
* customer picks from: "30 min - 1 hr", "1 day - 3 days". "" when the record has none. */
|
|
269
|
+
export function serviceDurationText(service: PricedServiceShape, label: BookingLabel): string {
|
|
270
|
+
const constraints = service.schedule?.availabilityConstraints;
|
|
271
|
+
const positive = (values: unknown[]) => values.map(finiteNumber).filter((n): n is number => n != null && n > 0);
|
|
272
|
+
const listed = positive([
|
|
273
|
+
...(constraints?.sessionDurations ?? []),
|
|
274
|
+
...(constraints?.durations ?? []).map((d) => d?.minutes),
|
|
275
|
+
]);
|
|
276
|
+
const hours = constraints?.durationRange?.hourOptions;
|
|
277
|
+
const range = positive([hours?.minDurationInMinutes, hours?.maxDurationInMinutes]);
|
|
278
|
+
const days = constraints?.durationRange?.dayOptions;
|
|
279
|
+
const dayRange = positive([days?.minDurationInDays, days?.maxDurationInDays]);
|
|
280
|
+
if (!listed.length && !range.length && dayRange.length) {
|
|
281
|
+
const dayText = (n: number) => (n === 1 ? label("day", "1 day") : label("days", "{n} days", { n }));
|
|
282
|
+
const first = Math.min(...dayRange);
|
|
283
|
+
const last = Math.max(...dayRange);
|
|
284
|
+
return first === last ? dayText(first) : `${dayText(first)} - ${dayText(last)}`;
|
|
285
|
+
}
|
|
286
|
+
const minutes = listed.length ? listed : range.length ? range : positive([service.duration]);
|
|
287
|
+
if (!minutes.length) return "";
|
|
288
|
+
const min = Math.min(...minutes);
|
|
289
|
+
const max = Math.max(...minutes);
|
|
290
|
+
return min === max ? minutesText(min) : `${minutesText(min)} - ${minutesText(max)}`;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function validDate(value: string | undefined): Date | undefined {
|
|
294
|
+
if (!value) return undefined;
|
|
295
|
+
const parts = /^(\d{4})-(\d{2})-(\d{2})(?:T|$)/i.exec(value);
|
|
296
|
+
if (!parts) return undefined;
|
|
297
|
+
const year = Number(parts[1]), month = Number(parts[2]) - 1, day = Number(parts[3]);
|
|
298
|
+
// Date accepts February 30 by rolling into March. Check the stated calendar day first;
|
|
299
|
+
// setUTCFullYear also preserves years 0–99, which Date.UTC would reinterpret as 1900–1999.
|
|
300
|
+
const calendar = new Date(0);
|
|
301
|
+
calendar.setUTCFullYear(year, month, day);
|
|
302
|
+
if (calendar.getUTCFullYear() !== year || calendar.getUTCMonth() !== month || calendar.getUTCDate() !== day) return undefined;
|
|
303
|
+
const date = new Date(value);
|
|
304
|
+
return Number.isFinite(date.getTime()) ? date : undefined;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function shortDate(date: Date, year: boolean): string {
|
|
308
|
+
return year ? formatDateMedium(date) : formatMonthDay(date);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** A course's dates, "Nov 3 – Dec 15, 2026" (the year on the first date only when the two
|
|
312
|
+
* differ). "" when the record has no first or last session. */
|
|
313
|
+
export function courseDatesText(service: PricedServiceShape): string {
|
|
314
|
+
const first = validDate(service.schedule?.firstSessionStart);
|
|
315
|
+
const last = validDate(service.schedule?.lastSessionEnd);
|
|
316
|
+
if (!first || !last) return "";
|
|
317
|
+
return `${shortDate(first, first.getFullYear() !== last.getFullYear())} – ${shortDate(last, true)}`;
|
|
318
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Copy-as-configuration for WORKER-emitted strings (`himi docs designing-himi-screens`,
|
|
2
|
+
// §"Copy is configuration"): a worker never hardcodes user-facing copy — the
|
|
3
|
+
// descriptor bakes the provisioned copy-pack overrides relevant to this worker
|
|
4
|
+
// into its onAppear action params as a `copy` JSON object (customer strings or
|
|
5
|
+
// source-matched stock translations, computed at descriptor-build time), and the
|
|
6
|
+
// worker reads every user-facing string through `copyParam(key, fallback)`.
|
|
7
|
+
//
|
|
8
|
+
// STASHED (the stashed appear-params idiom, himi-branded-lite-home): the
|
|
9
|
+
// param-carrying onAppear dispatch updates the stash; later arg-less calls
|
|
10
|
+
// (self-kick refreshes, retry buttons, pull-to-refresh) fall back to it, so
|
|
11
|
+
// resolution order can never drop the pack. With no pack the param is absent
|
|
12
|
+
// and every read returns `fallback` verbatim — routing a worker string through
|
|
13
|
+
// copyParam is byte-for-byte behavior-preserving.
|
|
14
|
+
//
|
|
15
|
+
// Pure + Hermes-safe (no host globals, no Node APIs; its only import is the pure `app-locale` sibling): bundled into
|
|
16
|
+
// every worker that emits user-facing copy, and copied verbatim into the
|
|
17
|
+
// generated templates' tier5-src/_shared/.
|
|
18
|
+
|
|
19
|
+
import { isSingular, setAppLocale, setBusinessTimeZone } from "./app-locale.js";
|
|
20
|
+
|
|
21
|
+
/** Customer strings override every read; translated stock is valid only for its
|
|
22
|
+
* original English fallback. Some existing keys serve more than one message. */
|
|
23
|
+
export type CopyPackValue = string | { source: string; translation: string };
|
|
24
|
+
|
|
25
|
+
let stashedCopy: Record<string, CopyPackValue> = Object.create(null);
|
|
26
|
+
/** Stock translations by the English text they replace, from the `textCopy` param. A pinned app's bake
|
|
27
|
+
* names each worker fallback its catalog translates by its text, because a catalog row for worker copy
|
|
28
|
+
* is often keyless. A key's own `copy` entry always wins over this. */
|
|
29
|
+
let stashedByText = new Map<string, string>();
|
|
30
|
+
let copyReceived = false;
|
|
31
|
+
|
|
32
|
+
/** Absorb the `copy` onAppear param (customer strings or stock translation records)
|
|
33
|
+
* from an action arg. Call first in every action that can receive onAppear
|
|
34
|
+
* params (load/refresh). Non-copy args and malformed packs are ignored — the
|
|
35
|
+
* stock fallbacks keep rendering. */
|
|
36
|
+
export function stashCopy(arg: unknown): void {
|
|
37
|
+
if (!arg || typeof arg !== "object") return;
|
|
38
|
+
// A param-carrying dispatch names the app language and business zone too (absent: the English house
|
|
39
|
+
// pattern, and no zone).
|
|
40
|
+
if ("copy" in arg || "locale" in arg || "businessTimeZone" in arg) {
|
|
41
|
+
setAppLocale((arg as Record<string, unknown>).locale);
|
|
42
|
+
setBusinessTimeZone((arg as Record<string, unknown>).businessTimeZone);
|
|
43
|
+
}
|
|
44
|
+
const text = (arg as Record<string, unknown>).textCopy;
|
|
45
|
+
if (typeof text === "string" && text) {
|
|
46
|
+
const parsed = parseTextCopy(text);
|
|
47
|
+
if (parsed) { stashedByText = parsed; copyReceived = true; }
|
|
48
|
+
}
|
|
49
|
+
const raw = (arg as Record<string, unknown>).copy;
|
|
50
|
+
if (typeof raw !== "string" || !raw) return;
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(raw) as unknown;
|
|
53
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return;
|
|
54
|
+
const next: Record<string, CopyPackValue> = Object.create(null);
|
|
55
|
+
for (const [key, value] of Object.entries(parsed as Record<string, unknown>)) {
|
|
56
|
+
if (typeof value === "string") next[key] = value;
|
|
57
|
+
else if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
58
|
+
const row = value as Record<string, unknown>;
|
|
59
|
+
if (typeof row.source === "string" && typeof row.translation === "string") {
|
|
60
|
+
next[key] = { source: row.source, translation: row.translation };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
stashedCopy = next;
|
|
65
|
+
copyReceived = true;
|
|
66
|
+
} catch {
|
|
67
|
+
// Malformed pack param — keep the stock copy rather than dying mid-action.
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** `textCopy`: a JSON object from English text to its translation. A malformed one is ignored (the
|
|
72
|
+
* stock copy keeps rendering); an entry that is not a non-empty string is dropped. */
|
|
73
|
+
function parseTextCopy(text: string): Map<string, string> | undefined {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(text) as unknown;
|
|
76
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return undefined;
|
|
77
|
+
const out = new Map<string, string>();
|
|
78
|
+
for (const [source, translation] of Object.entries(parsed as Record<string, unknown>)) {
|
|
79
|
+
if (typeof translation === "string" && translation !== "") out.set(source, translation);
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
} catch {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The provisioned override for `key`, or `fallback` (the stock copy). An optional
|
|
88
|
+
* restored label survives only until a current copy pack arrives. */
|
|
89
|
+
export function copyParam(key: string, fallback: string, restoredFallback = fallback): string {
|
|
90
|
+
const value = stashedCopy[key];
|
|
91
|
+
// A disk-restored row may paint before onAppear supplies its copy pack. Keep its
|
|
92
|
+
// last label only before a pack arrives; even an empty current pack selects stock copy.
|
|
93
|
+
if (value === undefined) return stashedByText.get(fallback) ?? (copyReceived ? fallback : restoredFallback);
|
|
94
|
+
// A key can serve two messages: a row for another source text, or an empty one, must not hide the stock translation
|
|
95
|
+
// the app's catalog has for the fallback actually passed.
|
|
96
|
+
if (typeof value === "string") return value !== "" ? value : stashedByText.get(fallback) ?? fallback;
|
|
97
|
+
return value?.source === fallback && value.translation !== "" ? value.translation : stashedByText.get(fallback) ?? fallback;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Interpolate `{name}` placeholders in a (possibly overridden) template:
|
|
101
|
+
* `copyTemplate("plans.joinOnSite", "…join {name}.", { name })`. Unknown
|
|
102
|
+
* placeholders resolve to "" so a typo'd override degrades, never crashes. */
|
|
103
|
+
export function copyTemplate(key: string, fallback: string, values: Record<string, string | number>): string {
|
|
104
|
+
return copyParam(key, fallback).replace(/\{([A-Za-z0-9_]+)\}/g, (_all, name: string) =>
|
|
105
|
+
name in values ? String(values[name]) : "",
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The small ICU plural form used by Bookings spot counts. The provisioned copy may
|
|
110
|
+
* translate both branches without adding a second key for the singular. */
|
|
111
|
+
export function copyPlural(key: string, fallback: string, count: number): string {
|
|
112
|
+
const pattern = copyParam(key, fallback);
|
|
113
|
+
const match = /^\{n, plural, one \{([^{}]*)\} other \{([^{}]*)\}\}$/.exec(pattern);
|
|
114
|
+
if (!match) return copyTemplate(key, fallback, { n: count });
|
|
115
|
+
return (isSingular(count) ? match[1] : match[2])!.replace(/#/g, String(count));
|
|
116
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Graduated to the SDK (SP-3): the store display helpers + v3 product query now live in
|
|
2
|
+
// @himalaya/wix-stores. This thin re-export keeps existing bundle imports working; new
|
|
3
|
+
// code should import from "@himalaya/wix-stores" directly.
|
|
4
|
+
// Relative so node (tests importing worker sources) resolves it too — the bare
|
|
5
|
+
// "@himalaya/wix-stores" name exists only in the esbuild alias map / the off-repo
|
|
6
|
+
// umbrella. gen-templates.mts rewrites this back to @himalaya/wix-stores off-repo.
|
|
7
|
+
export * from "@himalaya/wix-stores";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Shared display-text helpers for himi cards: trim catalog artifacts from titles and
|
|
2
|
+
// derive up-to-two-letter placeholder initials so same-first-letter lists still vary.
|
|
3
|
+
|
|
4
|
+
/** Trim trailing artifact markers (stray asterisks / footnote daggers) and whitespace
|
|
5
|
+
* that leak from test/seed catalogs, without touching interior punctuation. Falls back
|
|
6
|
+
* to the original when trimming would empty the string. */
|
|
7
|
+
export function cleanTitle(value?: string): string {
|
|
8
|
+
const raw = (value ?? "").trim();
|
|
9
|
+
const cleaned = raw.replace(/[\s*†‡]+$/u, "").trim();
|
|
10
|
+
return cleaned || raw;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Up to two significant initials for a placeholder avatar. Two-plus words → first
|
|
14
|
+
* letter of the first two; a single word → its first two alphanumerics. Keeps a list
|
|
15
|
+
* of similar names (e.g. many "Booking…") from collapsing to one identical glyph. */
|
|
16
|
+
export function initials(value?: string): string {
|
|
17
|
+
const words = (value ?? "").trim().split(/\s+/).filter(Boolean);
|
|
18
|
+
if (words.length === 0) return "#";
|
|
19
|
+
if (words.length === 1) {
|
|
20
|
+
const alnum = words[0].replace(/[^\p{L}\p{N}]/gu, "");
|
|
21
|
+
return (alnum.slice(0, 2) || "#").toUpperCase();
|
|
22
|
+
}
|
|
23
|
+
return ((words[0][0] ?? "") + (words[1][0] ?? "")).toUpperCase();
|
|
24
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Host events — what a member screen tells the app hosting it about something the member did
|
|
2
|
+
// (a booking confirmed or cancelled), so a host such as Symphony can say so in its chat and refresh
|
|
3
|
+
// what it shows.
|
|
4
|
+
//
|
|
5
|
+
// A worker dispatches `host.event` with `{ type, ...fields }` (string values only: a dispatch carries
|
|
6
|
+
// one string params map). An embed (`HimalayaEmbed`) hands it to the host's `onAction` as an action
|
|
7
|
+
// with that id; anywhere else nothing handles it and it is dropped. It is a notice, never a request:
|
|
8
|
+
// the host owns what happens next, and the worker never waits on it or depends on its answer.
|
|
9
|
+
//
|
|
10
|
+
// The contract (hosts parse exactly this — Symphony's `PlaceHostEvent`):
|
|
11
|
+
// type booking.created | booking.cancelled | plan.used
|
|
12
|
+
// serviceName the class / service title (bookings) planName the plan's name (plan.used)
|
|
13
|
+
// start, end ISO 8601 instants WITH an offset (`Z` or `+02:00`); a local time is left out
|
|
14
|
+
// remaining sessions left on the plan, when known (a whole number)
|
|
15
|
+
// bookingId, serviceId, planId when known
|
|
16
|
+
|
|
17
|
+
import { dispatch } from "@himalaya/dispatch";
|
|
18
|
+
|
|
19
|
+
export const HOST_EVENT_ACTION_ID = "host.event";
|
|
20
|
+
|
|
21
|
+
/** The events a member screen reports. */
|
|
22
|
+
export type HostEventType = "booking.created" | "booking.cancelled" | "plan.used";
|
|
23
|
+
|
|
24
|
+
export interface HostEventFields {
|
|
25
|
+
bookingId?: string;
|
|
26
|
+
serviceId?: string;
|
|
27
|
+
serviceName?: string;
|
|
28
|
+
planId?: string;
|
|
29
|
+
planName?: string;
|
|
30
|
+
start?: string;
|
|
31
|
+
end?: string;
|
|
32
|
+
remaining?: number | string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
36
|
+
|
|
37
|
+
/** [value] when it is an ISO 8601 instant that names its offset, else "". A slot's LOCAL wall time
|
|
38
|
+
* ("2026-11-02T18:30:00") would be read in the host's zone, i.e. a wrong hour, so it is left out. */
|
|
39
|
+
export function hostEventInstant(value: unknown): string {
|
|
40
|
+
return typeof value === "string" && WITH_OFFSET.test(value) && Number.isFinite(Date.parse(value)) ? value : "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The `host.event` params for [type] and [fields]: unset and empty fields are left out, times
|
|
44
|
+
* without an offset are left out, and `remaining` is a whole number ≥ 0 or nothing. */
|
|
45
|
+
export function hostEventParams(type: HostEventType, fields: HostEventFields = {}): Record<string, string> {
|
|
46
|
+
const params: Record<string, string> = { type };
|
|
47
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
48
|
+
let out = "";
|
|
49
|
+
if (key === "start" || key === "end") out = hostEventInstant(value);
|
|
50
|
+
else if (key === "remaining") {
|
|
51
|
+
const n = typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" ? Number(value) : NaN;
|
|
52
|
+
out = Number.isInteger(n) && n >= 0 ? String(n) : "";
|
|
53
|
+
} else if (typeof value === "string") out = value.trim();
|
|
54
|
+
if (out) params[key] = out;
|
|
55
|
+
}
|
|
56
|
+
return params;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Tell the host about [type]. Never throws: a host that does not listen must not break the screen. */
|
|
60
|
+
export async function emitHostEvent(type: HostEventType, fields: HostEventFields = {}): Promise<void> {
|
|
61
|
+
try {
|
|
62
|
+
await dispatch(HOST_EVENT_ACTION_ID, hostEventParams(type, fields));
|
|
63
|
+
} catch {
|
|
64
|
+
// Not embedded, or the host has no handler: nothing to tell.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Hosted checkout. A Branded Lite hosted in a host shell (Spaces) pays as the member the host
|
|
2
|
+
// lent it: Headless `createRedirectSession` does not take a Member instance, so the HOST opens the site's
|
|
3
|
+
// checkout signed in as that member. The worker names only its ecom checkout; the host reads Wix's
|
|
4
|
+
// checkout URL, mints a one-time member session and opens the site's `createSessionCookie` → checkout.
|
|
5
|
+
// The session token never reaches this worker.
|
|
6
|
+
//
|
|
7
|
+
// Classic Wix Events tickets and classic Pricing Plans have no ecom checkout: for those the
|
|
8
|
+
// worker names the page by id (`himi.host.memberSitePage`) and the host opens the site's own event or
|
|
9
|
+
// plans page the same way, signed in — where the member picks and pays on the site. A member's orders
|
|
10
|
+
// are the same (Wix lists them to no member identity), so My orders opens the site's own page too.
|
|
11
|
+
|
|
12
|
+
import { dispatch } from "@himalaya/dispatch";
|
|
13
|
+
import { hostSiteFromInput } from "./branded-lite-hosted.js";
|
|
14
|
+
|
|
15
|
+
/** The host verbs (registered by the host shell, never by the app itself). The first prepares the
|
|
16
|
+
* checkout and answers a one-time ticket; the second opens it. Two steps so the caller's charge guard
|
|
17
|
+
* is re-read after the host's network round trips and right before the checkout opens — the prepared
|
|
18
|
+
* URL (which carries the member's session token) stays in the host; only the ticket crosses here. */
|
|
19
|
+
export const HOSTED_CHECKOUT_ACTION = "himi.host.memberCheckout";
|
|
20
|
+
export const HOSTED_CHECKOUT_OPEN_ACTION = "himi.host.memberCheckout.open";
|
|
21
|
+
/** Prepares a site PAGE (not an ecom checkout) the same way; opened with [HOSTED_CHECKOUT_OPEN_ACTION]. */
|
|
22
|
+
export const HOSTED_SITE_PAGE_ACTION = "himi.host.memberSitePage";
|
|
23
|
+
|
|
24
|
+
/** A site page a hosted worker may ask its host for — ids only, never a URL: the host reads the URL
|
|
25
|
+
* from Wix itself and decides whether the member may be signed in there. */
|
|
26
|
+
export type HostedSitePage = { page: "event"; eventId: string } | { page: "plans"; planId?: string } | { page: "orders" };
|
|
27
|
+
|
|
28
|
+
/** Whether this worker runs inside a host that opened a site for it. */
|
|
29
|
+
export function isHostedWorker(): boolean {
|
|
30
|
+
return hostSiteFromInput((globalThis as { himalaya?: { input?: unknown } }).himalaya?.input) !== null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type HostAnswer = { opened?: unknown; ticket?: unknown; payload?: { opened?: unknown; ticket?: unknown } } | null;
|
|
34
|
+
type HostOpener = (stillMayCharge: () => Promise<boolean>) => Promise<boolean | "withdrawn">;
|
|
35
|
+
|
|
36
|
+
/** Prepare with [action] [params] → re-read the guard → open by ticket. A host without the verbs, or one
|
|
37
|
+
* that refused (Wix named no page, an unsafe URL, no account session), → false, never a throw. */
|
|
38
|
+
function hostOpener(action: string, params: Record<string, string>): HostOpener {
|
|
39
|
+
return async (stillMayCharge) => {
|
|
40
|
+
try {
|
|
41
|
+
const prepared = await dispatch(action, params) as HostAnswer;
|
|
42
|
+
const ticket = prepared?.ticket ?? prepared?.payload?.ticket;
|
|
43
|
+
if (typeof ticket !== "string" || !ticket) return false;
|
|
44
|
+
// An unopened ticket simply expires in the host: nothing to cancel.
|
|
45
|
+
if (!(await stillMayCharge())) return "withdrawn";
|
|
46
|
+
const result = await dispatch(HOSTED_CHECKOUT_OPEN_ACTION, { ticket }) as HostAnswer;
|
|
47
|
+
const opened = result?.opened ?? result?.payload?.opened;
|
|
48
|
+
return opened === true || opened === "true";
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `payCashierOrder`'s `openCashier` for a hosted app: the host prepares [checkoutId]'s checkout as the
|
|
56
|
+
* lent member, the caller's guard is re-read, and only then does the host open it. Resolves whether it
|
|
57
|
+
* opened ("withdrawn" when the guard said no); a host without the verbs (or that refused) → false. */
|
|
58
|
+
export function hostedCheckoutOpener(checkoutId: string): HostOpener {
|
|
59
|
+
return hostOpener(HOSTED_CHECKOUT_ACTION, { checkoutId });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The site's own [page] opened by the host, signed in as the lent member where the host deems it safe
|
|
63
|
+
* (a visitor otherwise) — the same two steps and answers as [hostedCheckoutOpener]. */
|
|
64
|
+
export function hostedSitePageOpener(page: HostedSitePage): HostOpener {
|
|
65
|
+
const params: Record<string, string> = page.page === "event"
|
|
66
|
+
? { page: "event", eventId: page.eventId }
|
|
67
|
+
: page.page === "orders" ? { page: "orders" }
|
|
68
|
+
: { page: "plans", ...(page.planId ? { planId: page.planId } : {}) };
|
|
69
|
+
return hostOpener(HOSTED_SITE_PAGE_ACTION, params);
|
|
70
|
+
}
|