@wix/agent-skills 1.20.1 → 1.22.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/package.json +1 -1
- package/skills/wix-app/SKILL.md +71 -113
- package/skills/wix-app/references/APP_TOOLS.md +2 -1
- package/skills/wix-app/references/BACKEND_EVENT.md +3 -3
- package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +41 -152
- package/skills/wix-app/references/DASHBOARD_MODAL.md +4 -4
- package/skills/wix-app/references/DASHBOARD_PAGE.md +11 -25
- package/skills/wix-app/references/DATA_COLLECTION.md +16 -219
- package/skills/wix-app/references/SDK_MODULE_MAP.md +44 -0
- package/skills/wix-app/references/SITE_PLUGIN.md +36 -190
- package/skills/wix-app/references/app-tools/TOOLS.md +3 -1
- package/skills/wix-app/references/custom-element-widget/SETTINGS_PANEL.md +21 -0
- package/skills/wix-app/references/dashboard-page/DATA_SOURCES.md +182 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE.md +97 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE_COLLECTION.md +184 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE_ROUTER.md +203 -0
- package/skills/wix-app/references/dashboard-page/DRAFT_TEMPLATE_SETTINGS.md +44 -0
- package/skills/wix-app/references/dashboard-page/ECOM_NAVIGATION.md +17 -0
- package/skills/wix-app/references/dashboard-page/QUERY_AND_PAGING.md +182 -0
- package/skills/wix-app/references/dashboard-page/TABLE_STATE.md +133 -0
- package/skills/wix-app/references/dashboard-page/UX_SUCCESS_MODEL.md +10 -5
- package/skills/wix-app/references/dashboard-plugin/SLOTS.md +4 -18
- package/skills/wix-app/references/data-collection/LIFECYCLE.md +68 -0
- package/skills/wix-app/references/data-collection/PERMISSIONS.md +47 -0
- package/skills/wix-app/references/data-collection/SCHEMA.md +181 -0
- package/skills/wix-app/references/data-collection/WIX_DATA.md +38 -66
- package/skills/wix-app/references/site-plugin/EXAMPLES.md +1 -1
- package/skills/wix-headless-fast/SKILL.md +144 -221
- package/skills/wix-headless-fast/cold-start/bootstrap.mjs +156 -0
- package/skills/wix-headless-fast/{entry/skill.md → cold-start/cold-start.md} +15 -15
- package/skills/wix-headless-fast/guides/existing-site.md +76 -0
- package/skills/wix-headless-fast/guides/reference-mode.md +97 -0
- package/skills/wix-headless-fast/install/AGENTS.md +35 -0
- package/skills/wix-headless-fast/install/agents-md.mjs +39 -0
- package/skills/wix-headless-fast/install/attach.mjs +161 -86
- package/skills/wix-headless-fast/install/deploy.mjs +21 -60
- package/skills/wix-headless-fast/install/lock.mjs +55 -0
- package/skills/wix-headless-fast/install/setup.mjs +259 -0
- package/skills/wix-headless-fast/install/templates.mjs +168 -0
- package/skills/wix-manage/references/ecommerce/pricing-promotions/ecom-pricing-create-coupon.md +10 -19
- package/skills/wix-manage/references/events/create-wix-event.md +5 -1
- package/skills/wix-manage/references/google-ads/google-ads-dashboard-navigation.md +27 -0
- package/skills/wix-manage/references/google-ads/manage-campaign-success-guide.md +83 -37
- package/skills/wix-headless-fast/install/fast-path.mjs +0 -181
- package/skills/wix-headless-fast/references/blog/INSTRUCTIONS.md +0 -301
- package/skills/wix-headless-fast/references/blog/app/components/blog/BlogFeedView.tsx +0 -136
- package/skills/wix-headless-fast/references/blog/app/components/blog/PostView.tsx +0 -112
- package/skills/wix-headless-fast/references/blog/app/components/blog/RichContent.tsx +0 -42
- package/skills/wix-headless-fast/references/blog/app/hooks/blog/useBlogFeed.ts +0 -31
- package/skills/wix-headless-fast/references/blog/app/hooks/blog/usePost.ts +0 -22
- package/skills/wix-headless-fast/references/blog/app/wix/blog/blog-feed-store.ts +0 -137
- package/skills/wix-headless-fast/references/blog/app/wix/blog/post-store.ts +0 -78
- package/skills/wix-headless-fast/references/blog/app/wix/blog/posts-core.ts +0 -117
- package/skills/wix-headless-fast/references/blog/app/wix/blog/posts.ts +0 -52
- package/skills/wix-headless-fast/references/blog/app/wix/blog/taxonomy-core.ts +0 -47
- package/skills/wix-headless-fast/references/blog/app/wix/blog/taxonomy.ts +0 -58
- package/skills/wix-headless-fast/references/blog/app/wix/blog/types.ts +0 -62
- package/skills/wix-headless-fast/references/blog/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/blog/app-astro/pages/blog/[...slug].astro +0 -97
- package/skills/wix-headless-fast/references/blog/app-astro/pages/blog.astro +0 -24
- package/skills/wix-headless-fast/references/blog/lock/astro/package-lock.json +0 -16156
- package/skills/wix-headless-fast/references/blog/rest/posts.ts +0 -42
- package/skills/wix-headless-fast/references/blog/rest/taxonomy.ts +0 -62
- package/skills/wix-headless-fast/references/blog/seed/SEED.md +0 -81
- package/skills/wix-headless-fast/references/blog/seed/seed-blog.mjs +0 -287
- package/skills/wix-headless-fast/references/bookings/INSTRUCTIONS.md +0 -275
- package/skills/wix-headless-fast/references/bookings/app/components/bookings/ServiceBookingView.tsx +0 -144
- package/skills/wix-headless-fast/references/bookings/app/components/bookings/ServicesView.tsx +0 -119
- package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useBookingFlow.ts +0 -32
- package/skills/wix-headless-fast/references/bookings/app/hooks/bookings/useServices.ts +0 -23
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking-core.ts +0 -218
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking-flow-store.ts +0 -169
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/booking.ts +0 -121
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services-core.ts +0 -92
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services-store.ts +0 -90
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/services.ts +0 -57
- package/skills/wix-headless-fast/references/bookings/app/wix/bookings/types.ts +0 -72
- package/skills/wix-headless-fast/references/bookings/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/bookings/app-astro/pages/services/[slug].astro +0 -76
- package/skills/wix-headless-fast/references/bookings/app-astro/pages/services.astro +0 -22
- package/skills/wix-headless-fast/references/bookings/lock/astro/package-lock.json +0 -11962
- package/skills/wix-headless-fast/references/bookings/rest/booking.ts +0 -113
- package/skills/wix-headless-fast/references/bookings/rest/services.ts +0 -55
- package/skills/wix-headless-fast/references/bookings/seed/SEED.md +0 -71
- package/skills/wix-headless-fast/references/bookings/seed/seed-bookings.mjs +0 -302
- package/skills/wix-headless-fast/references/cms/INSTRUCTIONS.md +0 -353
- package/skills/wix-headless-fast/references/cms/app/hooks/cms/useCollection.ts +0 -50
- package/skills/wix-headless-fast/references/cms/app/hooks/cms/useItem.ts +0 -37
- package/skills/wix-headless-fast/references/cms/app/wix/cms/collection-store.ts +0 -158
- package/skills/wix-headless-fast/references/cms/app/wix/cms/item-store.ts +0 -93
- package/skills/wix-headless-fast/references/cms/app/wix/cms/items-core.ts +0 -177
- package/skills/wix-headless-fast/references/cms/app/wix/cms/items.ts +0 -123
- package/skills/wix-headless-fast/references/cms/app/wix/cms/types.ts +0 -75
- package/skills/wix-headless-fast/references/cms/app-astro/layouts/SiteLayout.astro +0 -41
- package/skills/wix-headless-fast/references/cms/lock/astro/package-lock.json +0 -11262
- package/skills/wix-headless-fast/references/cms/rest/items.ts +0 -125
- package/skills/wix-headless-fast/references/cms/seed/SEED.md +0 -112
- package/skills/wix-headless-fast/references/cms/seed/seed-cms.mjs +0 -324
- package/skills/wix-headless-fast/references/events/INSTRUCTIONS.md +0 -305
- package/skills/wix-headless-fast/references/events/app/components/events/EventConfirmationView.tsx +0 -66
- package/skills/wix-headless-fast/references/events/app/components/events/EventRegistrationView.tsx +0 -178
- package/skills/wix-headless-fast/references/events/app/components/events/EventsView.tsx +0 -118
- package/skills/wix-headless-fast/references/events/app/hooks/events/useEventRegistration.ts +0 -35
- package/skills/wix-headless-fast/references/events/app/hooks/events/useEvents.ts +0 -24
- package/skills/wix-headless-fast/references/events/app/wix/events/events-core.ts +0 -130
- package/skills/wix-headless-fast/references/events/app/wix/events/events-store.ts +0 -97
- package/skills/wix-headless-fast/references/events/app/wix/events/events.ts +0 -55
- package/skills/wix-headless-fast/references/events/app/wix/events/registration-core.ts +0 -113
- package/skills/wix-headless-fast/references/events/app/wix/events/registration-store.ts +0 -156
- package/skills/wix-headless-fast/references/events/app/wix/events/registration.ts +0 -97
- package/skills/wix-headless-fast/references/events/app/wix/events/types.ts +0 -61
- package/skills/wix-headless-fast/references/events/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/events/app-astro/pages/event-confirmation.astro +0 -12
- package/skills/wix-headless-fast/references/events/app-astro/pages/events/[slug].astro +0 -80
- package/skills/wix-headless-fast/references/events/app-astro/pages/events.astro +0 -21
- package/skills/wix-headless-fast/references/events/lock/astro/package-lock.json +0 -11884
- package/skills/wix-headless-fast/references/events/rest/events.ts +0 -57
- package/skills/wix-headless-fast/references/events/rest/registration.ts +0 -83
- package/skills/wix-headless-fast/references/events/seed/SEED.md +0 -95
- package/skills/wix-headless-fast/references/events/seed/seed-events.mjs +0 -276
- package/skills/wix-headless-fast/references/forms/INSTRUCTIONS.md +0 -338
- package/skills/wix-headless-fast/references/forms/app/hooks/forms/useWixForm.ts +0 -85
- package/skills/wix-headless-fast/references/forms/app/wix/forms/form-store.ts +0 -332
- package/skills/wix-headless-fast/references/forms/app/wix/forms/forms-core.ts +0 -238
- package/skills/wix-headless-fast/references/forms/app/wix/forms/forms.ts +0 -54
- package/skills/wix-headless-fast/references/forms/app/wix/forms/submissions-core.ts +0 -216
- package/skills/wix-headless-fast/references/forms/app/wix/forms/submissions.ts +0 -59
- package/skills/wix-headless-fast/references/forms/app/wix/forms/types.ts +0 -135
- package/skills/wix-headless-fast/references/forms/lock/astro/package-lock.json +0 -10593
- package/skills/wix-headless-fast/references/forms/rest/forms.ts +0 -34
- package/skills/wix-headless-fast/references/forms/rest/submissions.ts +0 -56
- package/skills/wix-headless-fast/references/forms/seed/SEED.md +0 -116
- package/skills/wix-headless-fast/references/forms/seed/seed-forms.mjs +0 -327
- package/skills/wix-headless-fast/references/members/INSTRUCTIONS.md +0 -314
- package/skills/wix-headless-fast/references/members/app/components/members/AccountView.tsx +0 -60
- package/skills/wix-headless-fast/references/members/app/components/members/LoginForm.tsx +0 -155
- package/skills/wix-headless-fast/references/members/app/components/members/MemberMenu.tsx +0 -78
- package/skills/wix-headless-fast/references/members/app/components/members/RequireAuth.tsx +0 -47
- package/skills/wix-headless-fast/references/members/app/hooks/members/useMember.ts +0 -66
- package/skills/wix-headless-fast/references/members/app/wix/members/auth-core.ts +0 -105
- package/skills/wix-headless-fast/references/members/app/wix/members/auth.ts +0 -59
- package/skills/wix-headless-fast/references/members/app/wix/members/client.ts +0 -53
- package/skills/wix-headless-fast/references/members/app/wix/members/member-store.ts +0 -122
- package/skills/wix-headless-fast/references/members/app/wix/members/members-core.ts +0 -43
- package/skills/wix-headless-fast/references/members/app/wix/members/members.ts +0 -29
- package/skills/wix-headless-fast/references/members/app/wix/members/types.ts +0 -21
- package/skills/wix-headless-fast/references/members/app-astro/layouts/SiteLayout.astro +0 -42
- package/skills/wix-headless-fast/references/members/app-astro/pages/account.astro +0 -10
- package/skills/wix-headless-fast/references/members/app-astro/pages/login.astro +0 -11
- package/skills/wix-headless-fast/references/members/lock/astro/package-lock.json +0 -10329
- package/skills/wix-headless-fast/references/members/rest/auth.ts +0 -215
- package/skills/wix-headless-fast/references/members/rest/members.ts +0 -26
- package/skills/wix-headless-fast/references/members/seed/SEED.md +0 -39
- package/skills/wix-headless-fast/references/members/seed/seed-members.mjs +0 -94
- package/skills/wix-headless-fast/references/portfolio/INSTRUCTIONS.md +0 -313
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionProjectsView.tsx +0 -110
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/CollectionsView.tsx +0 -90
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/GalleryMedia.tsx +0 -35
- package/skills/wix-headless-fast/references/portfolio/app/components/portfolio/ProjectDetailView.tsx +0 -85
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollectionProjects.ts +0 -32
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useCollections.ts +0 -21
- package/skills/wix-headless-fast/references/portfolio/app/hooks/portfolio/useProjectDetail.ts +0 -31
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/collection-projects-store.ts +0 -82
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/collections-store.ts +0 -58
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/portfolio-core.ts +0 -177
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/portfolio.ts +0 -78
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/project-detail-store.ts +0 -81
- package/skills/wix-headless-fast/references/portfolio/app/wix/portfolio/types.ts +0 -55
- package/skills/wix-headless-fast/references/portfolio/app-astro/layouts/SiteLayout.astro +0 -40
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/portfolio/[slug].astro +0 -30
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/portfolio.astro +0 -21
- package/skills/wix-headless-fast/references/portfolio/app-astro/pages/projects/[slug].astro +0 -29
- package/skills/wix-headless-fast/references/portfolio/lock/astro/package-lock.json +0 -10197
- package/skills/wix-headless-fast/references/portfolio/rest/portfolio.ts +0 -75
- package/skills/wix-headless-fast/references/portfolio/seed/SEED.md +0 -86
- package/skills/wix-headless-fast/references/portfolio/seed/seed-portfolio.mjs +0 -258
- package/skills/wix-headless-fast/references/pricing-plans/INSTRUCTIONS.md +0 -294
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlanDetailView.tsx +0 -47
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/PlansView.tsx +0 -101
- package/skills/wix-headless-fast/references/pricing-plans/app/components/pricing-plans/SubscribeButton.tsx +0 -41
- package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlanPurchase.ts +0 -16
- package/skills/wix-headless-fast/references/pricing-plans/app/hooks/pricing-plans/usePlans.ts +0 -22
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plan-purchase-store.ts +0 -54
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans-core.ts +0 -106
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans-store.ts +0 -64
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/plans.ts +0 -27
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/purchase-core.ts +0 -43
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/purchase.ts +0 -22
- package/skills/wix-headless-fast/references/pricing-plans/app/wix/pricing-plans/types.ts +0 -30
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/layouts/SiteLayout.astro +0 -41
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/pages/plans/[slug].astro +0 -40
- package/skills/wix-headless-fast/references/pricing-plans/app-astro/pages/plans.astro +0 -21
- package/skills/wix-headless-fast/references/pricing-plans/lock/astro/package-lock.json +0 -11226
- package/skills/wix-headless-fast/references/pricing-plans/rest/plans.ts +0 -31
- package/skills/wix-headless-fast/references/pricing-plans/rest/purchase.ts +0 -20
- package/skills/wix-headless-fast/references/pricing-plans/seed/SEED.md +0 -79
- package/skills/wix-headless-fast/references/pricing-plans/seed/seed-pricing-plans.mjs +0 -279
- package/skills/wix-headless-fast/references/restaurants/INSTRUCTIONS.md +0 -358
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/MenuView.tsx +0 -142
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/OrderCartButton.tsx +0 -26
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/OrderCartDrawer.tsx +0 -121
- package/skills/wix-headless-fast/references/restaurants/app/components/restaurants/ReservationView.tsx +0 -155
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useMenus.ts +0 -34
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useOrderCart.ts +0 -43
- package/skills/wix-headless-fast/references/restaurants/app/hooks/restaurants/useReservation.ts +0 -34
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu-core.ts +0 -155
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu-store.ts +0 -89
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/menu.ts +0 -71
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/order-store.ts +0 -103
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/ordering-core.ts +0 -124
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/ordering.ts +0 -185
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservation-store.ts +0 -193
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservations-core.ts +0 -94
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/reservations.ts +0 -74
- package/skills/wix-headless-fast/references/restaurants/app/wix/restaurants/types.ts +0 -168
- package/skills/wix-headless-fast/references/restaurants/app-astro/layouts/SiteLayout.astro +0 -47
- package/skills/wix-headless-fast/references/restaurants/app-astro/pages/menu.astro +0 -22
- package/skills/wix-headless-fast/references/restaurants/app-astro/pages/reservations.astro +0 -12
- package/skills/wix-headless-fast/references/restaurants/lock/astro/package-lock.json +0 -12560
- package/skills/wix-headless-fast/references/restaurants/rest/menu.ts +0 -60
- package/skills/wix-headless-fast/references/restaurants/rest/ordering.ts +0 -169
- package/skills/wix-headless-fast/references/restaurants/rest/reservations.ts +0 -68
- package/skills/wix-headless-fast/references/restaurants/seed/SEED.md +0 -89
- package/skills/wix-headless-fast/references/restaurants/seed/seed-restaurants.mjs +0 -479
- package/skills/wix-headless-fast/references/shared/CONTENT.md +0 -22
- package/skills/wix-headless-fast/references/shared/CUSTOM_OPERATIONS.md +0 -73
- package/skills/wix-headless-fast/references/shared/DESIGN.md +0 -26
- package/skills/wix-headless-fast/references/shared/SUPPLIED-CONTENT.md +0 -23
- package/skills/wix-headless-fast/references/shared/app/styles/global.css +0 -52
- package/skills/wix-headless-fast/references/shared/app/wix/config.ts +0 -15
- package/skills/wix-headless-fast/references/shared/app/wix/media.ts +0 -81
- package/skills/wix-headless-fast/references/shared/app/wix/money.ts +0 -24
- package/skills/wix-headless-fast/references/shared/app/wix/sdk.ts +0 -89
- package/skills/wix-headless-fast/references/shared/capabilities/media-upload/app/wix/media-upload/client.ts +0 -46
- package/skills/wix-headless-fast/references/shared/capabilities/media-upload/app-astro/pages/api/wix/media-upload.ts +0 -46
- package/skills/wix-headless-fast/references/shared/rest/client.ts +0 -155
- package/skills/wix-headless-fast/references/shared/rest/config.ts +0 -3
- package/skills/wix-headless-fast/references/shared/rest/media.ts +0 -65
- package/skills/wix-headless-fast/references/shared/seed/images.mjs +0 -145
- package/skills/wix-headless-fast/references/storefront/INSTRUCTIONS.md +0 -608
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/CartButton.tsx +0 -26
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/CartDrawer.tsx +0 -155
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/FilterPanel.tsx +0 -266
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/OptionPicker.tsx +0 -95
- package/skills/wix-headless-fast/references/storefront/app/components/storefront/QuickAdd.tsx +0 -136
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useCart.ts +0 -48
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useProductDetail.ts +0 -39
- package/skills/wix-headless-fast/references/storefront/app/hooks/storefront/useShop.ts +0 -34
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart-core.ts +0 -121
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart-store.ts +0 -107
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/cart.ts +0 -138
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/catalog-core.ts +0 -309
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/catalog.ts +0 -133
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/product-detail-store.ts +0 -147
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/shop-store.ts +0 -289
- package/skills/wix-headless-fast/references/storefront/app/wix/storefront/types.ts +0 -167
- package/skills/wix-headless-fast/references/storefront/app-astro/layouts/SiteLayout.astro +0 -65
- package/skills/wix-headless-fast/references/storefront/lock/astro/package-lock.json +0 -12247
- package/skills/wix-headless-fast/references/storefront/rest/cart.ts +0 -132
- package/skills/wix-headless-fast/references/storefront/rest/catalog.ts +0 -123
- package/skills/wix-headless-fast/references/storefront/seed/SEED.md +0 -124
- package/skills/wix-headless-fast/references/storefront/seed/seed-store.mjs +0 -525
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Plan reads over REST — the twin of app/wix/pricing-plans/plans.ts. Same exports, same DTOs; the
|
|
2
|
-
// rules and mappers come from plans-core (the SAME file the SDK transport uses, deployed flat next
|
|
3
|
-
// to this one by deploy.mjs --stack static), so this file is only the transport: one fetch with a
|
|
4
|
-
// literal body per function. Every call here is safe from a browser with a visitor token.
|
|
5
|
-
// Porting: keep the path, keep the body, port the core once.
|
|
6
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/pricing-plans/plans-v3/query-plans.md
|
|
7
|
-
import { wixRequest } from "./client.js";
|
|
8
|
-
import { imgSrc } from "./media.js";
|
|
9
|
-
import { plansQuery, toDetail, toSummary, type Raw } from "./plans-core.js";
|
|
10
|
-
import type { PlanDetail, PlanSummary } from "./types.js";
|
|
11
|
-
|
|
12
|
-
const QUERY = "/pricing-plans/v3/plans/query";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The public plans for the pricing grid, as card-ready DTOs.
|
|
16
|
-
* POST /pricing-plans/v3/plans/query { query: { filter: { visibility: "PUBLIC" }, cursorPaging: { limit } } }
|
|
17
|
-
*/
|
|
18
|
-
export async function fetchPlans({ limit = 100 } = {}): Promise<PlanSummary[]> {
|
|
19
|
-
const res = await wixRequest<Raw>(QUERY, { body: { query: plansQuery({ limit }) } });
|
|
20
|
-
return ((res?.plans ?? []) as Raw[]).map((p) => toSummary(p, imgSrc));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* One public plan by its URL slug; null when the slug doesn't resolve (an empty `plans`, not a 404).
|
|
25
|
-
* POST /pricing-plans/v3/plans/query { query: { filter: { visibility: "PUBLIC", slug }, cursorPaging: { limit: 1 } } }
|
|
26
|
-
*/
|
|
27
|
-
export async function fetchPlanBySlug(slug: string): Promise<PlanDetail | null> {
|
|
28
|
-
const res = await wixRequest<Raw>(QUERY, { body: { query: plansQuery({ limit: 1, slug }) } });
|
|
29
|
-
const raw: Raw | undefined = res?.plans?.[0];
|
|
30
|
-
return raw ? toDetail(raw, imgSrc) : null;
|
|
31
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// The purchase flow over REST — the twin of app/wix/pricing-plans/purchase.ts. Same export, same
|
|
2
|
-
// signature; the body and the result reading come from purchase-core (the SAME file the SDK
|
|
3
|
-
// transport uses). Purchasing is a MEMBER action, but the hosted flow handles login/signup, the
|
|
4
|
-
// order form, and payment itself, so a visitor token starts it. Never create the order yourself,
|
|
5
|
-
// never hand-build a checkout URL.
|
|
6
|
-
// docs: https://dev.wix.com/docs/api-reference/business-management/headless/redirects/create-redirect-session.md
|
|
7
|
-
import { wixRequest } from "./client.js";
|
|
8
|
-
import { purchaseBody, redirectUrl, type PurchaseOptions } from "./purchase-core.js";
|
|
9
|
-
import type { Raw } from "./plans-core.js";
|
|
10
|
-
|
|
11
|
-
export type { PurchaseOptions };
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Start the hosted purchase for a plan; resolves to the URL to navigate the FULL document to.
|
|
15
|
-
* POST /headless/v1/redirect-session { paidPlansCheckout: { planId }, callbacks: { postFlowUrl, thankYouPageUrl? } }
|
|
16
|
-
*/
|
|
17
|
-
export async function purchasePlan(planId: string, options: PurchaseOptions = {}): Promise<string> {
|
|
18
|
-
const session = await wixRequest<Raw>("/headless/v1/redirect-session", { body: purchaseBody(planId, options) });
|
|
19
|
-
return redirectUrl(session);
|
|
20
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# Pricing Plans — seeding
|
|
2
|
-
|
|
3
|
-
Seed by **running `seed-pricing-plans.mjs` with a plan file** — don't hand-write the REST
|
|
4
|
-
calls. The script mints its own site token via the Wix CLI (logged-in session +
|
|
5
|
-
`wix.config.json` required), installs the Pricing Plans app if needed, and creates everything
|
|
6
|
-
in the right order.
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
# from the project root (where wix.config.json lives):
|
|
10
|
-
node <SKILL_ROOT>/references/pricing-plans/seed/seed-pricing-plans.mjs plan.json
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`plan.json` is plain data — write it from the brief. **Default to 3 plans** — a tier ladder
|
|
14
|
-
the grid can render (e.g. free / monthly / yearly), each with 3–4 perks; together they
|
|
15
|
-
exercise every price shape the UI handles. Plans have no seedable images (the owner adds one
|
|
16
|
-
per plan in the dashboard).
|
|
17
|
-
|
|
18
|
-
```json
|
|
19
|
-
{
|
|
20
|
-
"plans": [
|
|
21
|
-
{ "name": "Community", "type": "free",
|
|
22
|
-
"description": "Get a taste — member perks, zero commitment.",
|
|
23
|
-
"perks": ["Member-only newsletter", "Community events access"] },
|
|
24
|
-
{ "name": "Studio Membership", "price": "29.00",
|
|
25
|
-
"type": "recurring", "billingCycle": { "period": "MONTH", "count": 1 },
|
|
26
|
-
"description": "The full experience, month to month.",
|
|
27
|
-
"perks": ["Unlimited group classes", "10% off workshops", "Priority booking"] },
|
|
28
|
-
{ "name": "Annual Pass", "price": "290.00",
|
|
29
|
-
"type": "recurring", "billingCycle": { "period": "YEAR", "count": 1 },
|
|
30
|
-
"description": "Two months free, billed yearly.",
|
|
31
|
-
"perks": ["Everything in Studio Membership", "2 guest passes", "Annual member gift"] }
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
- `type` — `"recurring"` (default; `billingCycle` defaults to `{ "period": "MONTH", "count": 1 }`),
|
|
37
|
-
`"one-time"` (bills once, then ends; `billingCycle: null` makes it never expire), or
|
|
38
|
-
`"free"` (amount forced to `"0"` + a per-member-lifetime purchase limit).
|
|
39
|
-
- `price` — a decimal string (`"29.00"`; a number is stringified). Currency is site-derived —
|
|
40
|
-
never sent.
|
|
41
|
-
- `perks` — display-only bullets on the plan card; they grant nothing by themselves.
|
|
42
|
-
- `termsAndConditions` (plain text), `visibility` (`"PUBLIC"`), `buyable` (`true`) — optional
|
|
43
|
-
overrides. A `buyable: false` plan renders without a subscribe CTA (merchant-assigned).
|
|
44
|
-
|
|
45
|
-
## Covering bookings services (only when bookings is also seeded)
|
|
46
|
-
|
|
47
|
-
A plan can COVER bookings services — members then book them with the membership. The link
|
|
48
|
-
goes through the Benefit Programs API, not the plan object, keyed by the **bookings seed's
|
|
49
|
-
service ids** — so seed bookings FIRST, then pass the ids:
|
|
50
|
-
|
|
51
|
-
```json
|
|
52
|
-
{ "name": "Studio Membership", "price": "29.00",
|
|
53
|
-
"perks": ["Unlimited group classes"],
|
|
54
|
-
"coveredServiceIds": ["<bookings service id>", "…"] }
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Unlimited coverage is the default; a limited pack (e.g. 8 sessions) instead uses
|
|
58
|
-
`"bookingsCoverage": { "serviceIds": [...], "creditAmount": 8 }`. A plans-only run just
|
|
59
|
-
omits both — coverage is skipped automatically.
|
|
60
|
-
|
|
61
|
-
**Seeding is additive — never delete or overwrite existing content**; ask first if a cleanup
|
|
62
|
-
seems needed.
|
|
63
|
-
|
|
64
|
-
## Supplied content
|
|
65
|
-
|
|
66
|
-
The general rules are in `references/shared/SUPPLIED-CONTENT.md`. For pricing plans, each plan the
|
|
67
|
-
user lists is one entry. Its name becomes `name`; a price with a billing period becomes `price`
|
|
68
|
-
with `type: "recurring"` and the matching `billingCycle`; a price paid once becomes
|
|
69
|
-
`type: "one-time"`; no price means `type: "free"`; a list of features or benefits becomes `perks`;
|
|
70
|
-
the description becomes `description`. A price with no period is a question for the user.
|
|
71
|
-
|
|
72
|
-
## Escape hatch — individual functions
|
|
73
|
-
`setupPricingPlans` composes exported steps — `installPricingPlansApp`, `createPlans`,
|
|
74
|
-
`attachBookingsCoverage` (and its `getProgramDefinition`, `createPoolDefinition`,
|
|
75
|
-
`createBenefitItems` sub-steps), plus `makeCtx()` — import them only for a partial re-seed.
|
|
76
|
-
|
|
77
|
-
## Reference
|
|
78
|
-
Unexpected shape or an uncovered operation → read the live Wix API reference; the
|
|
79
|
-
authoritative source recipe is `wix-headless/references/inline-recipes/setup-pricing-plans.md`.
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
// Pricing Plans seed — a BUILD-TIME script, never shipped in the app. Run from the project
|
|
2
|
-
// root (where wix.config.json lives) with a plan file:
|
|
3
|
-
//
|
|
4
|
-
// node <SKILL_ROOT>/references/pricing-plans/seed/seed-pricing-plans.mjs plan.json
|
|
5
|
-
//
|
|
6
|
-
// It mints its own site token via the Wix CLI, installs the Wix Pricing Plans app if needed,
|
|
7
|
-
// creates the plans (Plans V3 — one create call per plan; there is no bulk-create), and —
|
|
8
|
-
// only when a plan carries bookings service ids — wires the plan to COVER those services
|
|
9
|
-
// through the Benefit Programs API. Prints a JSON result to stdout.
|
|
10
|
-
//
|
|
11
|
-
// Plan shape (see SEED.md):
|
|
12
|
-
// { "plans": [{ "name", "description"?, "price"? (decimal string; a number is stringified),
|
|
13
|
-
// "type"?: "recurring"|"one-time"|"free",
|
|
14
|
-
// "billingCycle"?: { "period": "DAY"|"WEEK"|"MONTH"|"YEAR", "count" } | null,
|
|
15
|
-
// "perks"?: ["..."], "termsAndConditions"?, "visibility"?, "buyable"?,
|
|
16
|
-
// "coveredServiceIds"?: ["<bookings service id>"],
|
|
17
|
-
// "bookingsCoverage"?: { "serviceIds"?, "creditAmount"? } }] }
|
|
18
|
-
//
|
|
19
|
-
// Seeding is ADDITIVE — never deletes or overwrites existing content. Unexpected shapes →
|
|
20
|
-
// read the live API reference; authoritative source recipe:
|
|
21
|
-
// wix-headless/references/inline-recipes/setup-pricing-plans.md.
|
|
22
|
-
import { execFileSync } from "node:child_process";
|
|
23
|
-
import { readFileSync } from "node:fs";
|
|
24
|
-
import { randomUUID } from "node:crypto";
|
|
25
|
-
|
|
26
|
-
const API = "https://www.wixapis.com";
|
|
27
|
-
const PRICING_PLANS_APP_ID = "1522827f-c56c-a5c9-2ac9-00f9e6ae12d3";
|
|
28
|
-
const BOOKINGS_APP_ID = "13d21c63-b5ec-5912-8397-c3a5ddb27a97"; // coverage providerAppId — NOT the Plans id
|
|
29
|
-
const PP_NAMESPACE = "@wix/pricing-plans"; // literal, with the @ and the slash, in every coverage call
|
|
30
|
-
|
|
31
|
-
export function makeCtx({ cwd = process.cwd() } = {}) {
|
|
32
|
-
const config = JSON.parse(readFileSync(`${cwd}/wix.config.json`, "utf8"));
|
|
33
|
-
const siteId = config.siteId ?? config.projectId;
|
|
34
|
-
if (!siteId) throw new Error("wix.config.json has no siteId — is this a Wix CLI project?");
|
|
35
|
-
const token = execFileSync("npx", ["@wix/cli@latest", "token", "--site", siteId], {
|
|
36
|
-
encoding: "utf8",
|
|
37
|
-
cwd,
|
|
38
|
-
}).trim();
|
|
39
|
-
if (!token) throw new Error("The Wix CLI returned no token — run `npx @wix/cli@latest login` first.");
|
|
40
|
-
return { token, siteId };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
async function req(ctx, path, { method = "POST", body } = {}) {
|
|
44
|
-
const res = await fetch(API + path, {
|
|
45
|
-
method,
|
|
46
|
-
headers: {
|
|
47
|
-
Authorization: `Bearer ${ctx.token}`,
|
|
48
|
-
"wix-site-id": ctx.siteId,
|
|
49
|
-
"Content-Type": "application/json",
|
|
50
|
-
},
|
|
51
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
52
|
-
});
|
|
53
|
-
const json = await res.json().catch(() => ({}));
|
|
54
|
-
if (!res.ok) throw new Error(`${method} ${path} -> ${res.status}: ${JSON.stringify(json).slice(0, 400)}`);
|
|
55
|
-
return json;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
59
|
-
|
|
60
|
-
// billingTerms selects the plan type (recurring | one-time | free). recurring: billingCycle
|
|
61
|
-
// {period,count} (default MONTH/1) + ON_PURCHASE + UNTIL_CANCELLED. one-time: endType
|
|
62
|
-
// CYCLES_COMPLETED + billingCycleCount 1 (bill once, then ends); an unlimited one-time
|
|
63
|
-
// instead sets billingCycle:null + UNTIL_CANCELLED. free: MUST be the no-cycle unlimited
|
|
64
|
-
// shape — a $0 variant with a billingCycle is rejected ("Free pricing variant cannot be
|
|
65
|
-
// recurring").
|
|
66
|
-
function buildBillingTerms(plan) {
|
|
67
|
-
const type = plan.type || "recurring";
|
|
68
|
-
if (type === "free") {
|
|
69
|
-
return { billingCycle: null, startType: "ON_PURCHASE", endType: "UNTIL_CANCELLED" };
|
|
70
|
-
}
|
|
71
|
-
if (type === "one-time") {
|
|
72
|
-
if (plan.billingCycle === null) {
|
|
73
|
-
return { billingCycle: null, startType: "ON_PURCHASE", endType: "UNTIL_CANCELLED" };
|
|
74
|
-
}
|
|
75
|
-
const cycle = plan.billingCycle || { period: "MONTH", count: 1 };
|
|
76
|
-
return {
|
|
77
|
-
billingCycle: cycle,
|
|
78
|
-
startType: "ON_PURCHASE",
|
|
79
|
-
endType: "CYCLES_COMPLETED",
|
|
80
|
-
cyclesCompletedDetails: { billingCycleCount: 1 },
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
// recurring
|
|
84
|
-
const cycle = plan.billingCycle || { period: "MONTH", count: 1 };
|
|
85
|
-
return { billingCycle: cycle, startType: "ON_PURCHASE", endType: "UNTIL_CANCELLED" };
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// One pricingVariant with one pricingStrategy (schema allows ≤20 but is "currently limited
|
|
89
|
-
// to 1"). Amounts are decimal STRINGS ("20.00"); the variant id is a REQUIRED
|
|
90
|
-
// client-supplied GUID — omitting it returns 400.
|
|
91
|
-
function buildPricingVariant(plan) {
|
|
92
|
-
const free = (plan.type || "recurring") === "free";
|
|
93
|
-
const amount = free ? "0" : String(plan.price);
|
|
94
|
-
return {
|
|
95
|
-
id: randomUUID(),
|
|
96
|
-
name: plan.variantName || "Standard",
|
|
97
|
-
billingTerms: buildBillingTerms(plan),
|
|
98
|
-
pricingStrategies: [{ flatRate: { amount } }],
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// plain plan -> Plans V3 create body. status:"ACTIVE" is REQUIRED (omitting → 400
|
|
103
|
-
// "status value is required"); currency is NOT sent (read-only, site-derived); perks are
|
|
104
|
-
// display-only bullets, each with a REQUIRED client-supplied GUID.
|
|
105
|
-
function buildPlan(plan) {
|
|
106
|
-
const free = (plan.type || "recurring") === "free";
|
|
107
|
-
return {
|
|
108
|
-
name: plan.name,
|
|
109
|
-
description: plan.description,
|
|
110
|
-
status: "ACTIVE",
|
|
111
|
-
visibility: plan.visibility || "PUBLIC",
|
|
112
|
-
buyable: plan.buyable ?? true,
|
|
113
|
-
buyerCanCancel: plan.buyerCanCancel ?? true,
|
|
114
|
-
...(plan.termsAndConditions ? { termsAndConditions: plan.termsAndConditions } : {}),
|
|
115
|
-
pricingVariants: [buildPricingVariant(plan)],
|
|
116
|
-
perks: (plan.perks ?? []).map((p) => ({
|
|
117
|
-
id: randomUUID(),
|
|
118
|
-
description: typeof p === "string" ? p : p.description,
|
|
119
|
-
})),
|
|
120
|
-
// free: cap lifetime reuse. Array + maxCount per the SDK schema (PurchaseLimit[]); the
|
|
121
|
-
// recipe's older `{ type, count }` object form predates it.
|
|
122
|
-
...(free ? { purchaseLimits: [{ type: "PER_MEMBER_LIFETIME", maxCount: 1 }] } : {}),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// ---- operations ----------------------------------------------------------------------------------
|
|
127
|
-
|
|
128
|
-
// docs: https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/platform/about-apps-created-by-wix.md
|
|
129
|
-
export async function installPricingPlansApp(ctx) {
|
|
130
|
-
try {
|
|
131
|
-
await req(ctx, "/apps-installer-service/v1/app-instance/install", { body: {
|
|
132
|
-
tenant: { tenantType: "SITE", id: ctx.siteId },
|
|
133
|
-
appInstance: { appDefId: PRICING_PLANS_APP_ID, enabled: true },
|
|
134
|
-
} });
|
|
135
|
-
} catch {
|
|
136
|
-
/* already installed is fine */
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Create the plan(s) — Plans V3 has NO bulk-create: one POST per plan. Keep plan.id: the
|
|
141
|
-
// frontend orders by it AND it is the coverage externalId.
|
|
142
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/pricing-plans/plans-v3/create-plan.md
|
|
143
|
-
export async function createPlans(ctx, plans) {
|
|
144
|
-
const out = [];
|
|
145
|
-
for (const plan of plans) {
|
|
146
|
-
const r = await req(ctx, "/pricing-plans/v3/plans", { body: { plan: buildPlan(plan) } });
|
|
147
|
-
out.push({
|
|
148
|
-
id: r.plan?.id,
|
|
149
|
-
slug: r.plan?.slug,
|
|
150
|
-
name: plan.name,
|
|
151
|
-
coveredServiceIds: plan.coveredServiceIds,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return out;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// ---- bookings coverage via Benefit Programs (SKIP when no bookings in the run) -------------------
|
|
158
|
-
// Strictly ordered: plan.id -> programDefinition.id -> itemSetId -> items. Do NOT parallelize.
|
|
159
|
-
|
|
160
|
-
// 2a: READ the auto-created program definition (the Plans app creates it; you never create
|
|
161
|
-
// it). Provisioning is ~immediate but async — retry ONCE after a short backoff, don't loop.
|
|
162
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/program-definitions/introduction.md
|
|
163
|
-
export async function getProgramDefinition(ctx, planId) {
|
|
164
|
-
const path = `/benefit-programs/v1/program-definitions/by-namespace-and-external-id?externalId=${planId}&namespace=${encodeURIComponent(PP_NAMESPACE)}`;
|
|
165
|
-
try {
|
|
166
|
-
const r = await req(ctx, path, { method: "GET" });
|
|
167
|
-
if (r.programDefinition?.id) return r.programDefinition.id;
|
|
168
|
-
} catch {
|
|
169
|
-
/* fall through to the single insurance retry */
|
|
170
|
-
}
|
|
171
|
-
await sleep(1000);
|
|
172
|
-
const r = await req(ctx, path, { method: "GET" });
|
|
173
|
-
return r.programDefinition?.id;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// 2b: create ONE pool definition with EXACTLY ONE benefit naming Bookings as the provider.
|
|
177
|
-
// price "0" = unlimited (default; no creditConfiguration). Limited pack: pass creditAmount →
|
|
178
|
-
// price "1" + details.creditConfiguration (a SIBLING of benefits[], NOT inside a benefit —
|
|
179
|
-
// nesting it 400s with "Price should be 0 when credit pool is not set up").
|
|
180
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pool-definitions/create-pool-definition.md
|
|
181
|
-
export async function createPoolDefinition(ctx, programDefinitionId, { creditAmount } = {}) {
|
|
182
|
-
const limited = creditAmount != null;
|
|
183
|
-
const details = {
|
|
184
|
-
...(limited ? { creditConfiguration: { amount: String(creditAmount) } } : {}),
|
|
185
|
-
benefits: [
|
|
186
|
-
{
|
|
187
|
-
benefitKey: randomUUID(),
|
|
188
|
-
displayName: "Bookings sessions",
|
|
189
|
-
providerAppId: BOOKINGS_APP_ID,
|
|
190
|
-
price: limited ? "1" : "0",
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
};
|
|
194
|
-
const r = await req(ctx, "/benefit-programs/v1/pool-definitions", {
|
|
195
|
-
body: {
|
|
196
|
-
poolDefinition: {
|
|
197
|
-
namespace: PP_NAMESPACE,
|
|
198
|
-
displayName: "Bookings benefit",
|
|
199
|
-
programDefinitionIds: [programDefinitionId],
|
|
200
|
-
details,
|
|
201
|
-
},
|
|
202
|
-
cascade: "IMMEDIATELY",
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
// itemSetId lives at poolDefinition.details.benefits[i].itemSetId — one benefit here, so [0].
|
|
206
|
-
return r.poolDefinition?.details?.benefits?.[0]?.itemSetId;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// 2c: bulk-create the benefit items — ONE item per covered service (externalId = bookings
|
|
210
|
-
// service id). Up to 100 per call; category is an empty string; namespace/providerAppId
|
|
211
|
-
// repeat 2b's values.
|
|
212
|
-
// docs: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/items/bulk-create-items.md
|
|
213
|
-
export async function createBenefitItems(ctx, itemSetId, serviceIds) {
|
|
214
|
-
return req(ctx, "/benefit-programs/v1/bulk/items/create", {
|
|
215
|
-
body: {
|
|
216
|
-
items: serviceIds.map((externalId) => ({
|
|
217
|
-
namespace: PP_NAMESPACE,
|
|
218
|
-
category: "",
|
|
219
|
-
providerAppId: BOOKINGS_APP_ID,
|
|
220
|
-
itemSetId,
|
|
221
|
-
externalId,
|
|
222
|
-
})),
|
|
223
|
-
returnEntity: true,
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Wire a plan to COVER bookings services (per plan). Runs 2a → 2b → 2c in order.
|
|
230
|
-
* serviceIds come from the BOOKINGS seed — seed bookings first.
|
|
231
|
-
*/
|
|
232
|
-
export async function attachBookingsCoverage(ctx, planId, serviceIds, { creditAmount } = {}) {
|
|
233
|
-
const programDefinitionId = await getProgramDefinition(ctx, planId);
|
|
234
|
-
if (!programDefinitionId) throw new Error(`No program definition for plan ${planId} — is the Pricing Plans app installed?`);
|
|
235
|
-
const itemSetId = await createPoolDefinition(ctx, programDefinitionId, { creditAmount });
|
|
236
|
-
await createBenefitItems(ctx, itemSetId, serviceIds);
|
|
237
|
-
return { itemSetId, serviceIds };
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* ONE-CALL seed: install → create plans (ids kept in memory) → per covering plan, wire
|
|
242
|
-
* bookings coverage (2a → 2b → 2c, strictly ordered). The default path.
|
|
243
|
-
*/
|
|
244
|
-
export async function setupPricingPlans(ctx, { plans = [] } = {}) {
|
|
245
|
-
await installPricingPlansApp(ctx);
|
|
246
|
-
const created = await createPlans(ctx, plans);
|
|
247
|
-
const coverageAttached = [];
|
|
248
|
-
for (let i = 0; i < created.length; i++) {
|
|
249
|
-
const cov = plans[i].bookingsCoverage || {};
|
|
250
|
-
const serviceIds = cov.serviceIds || created[i].coveredServiceIds;
|
|
251
|
-
if (!serviceIds?.length) continue; // plans-only plan — coverage skipped
|
|
252
|
-
const r = await attachBookingsCoverage(ctx, created[i].id, serviceIds, { creditAmount: cov.creditAmount });
|
|
253
|
-
coverageAttached.push({ planId: created[i].id, ...r });
|
|
254
|
-
}
|
|
255
|
-
return {
|
|
256
|
-
plans: created,
|
|
257
|
-
coverageAttached,
|
|
258
|
-
benefitsCreated: coverageAttached.reduce((n, c) => n + c.serviceIds.length, 0),
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// ---- CLI entry ----------------------------------------------------------------------------------
|
|
263
|
-
|
|
264
|
-
const invokedDirectly = process.argv[1] && import.meta.url.endsWith(process.argv[1].split("/").pop());
|
|
265
|
-
if (invokedDirectly) {
|
|
266
|
-
const planPath = process.argv[2];
|
|
267
|
-
if (!planPath) {
|
|
268
|
-
console.error("usage: node seed-pricing-plans.mjs <plan.json> (run from the project root)");
|
|
269
|
-
process.exit(1);
|
|
270
|
-
}
|
|
271
|
-
const plan = JSON.parse(readFileSync(planPath, "utf8"));
|
|
272
|
-
const ctx = makeCtx();
|
|
273
|
-
setupPricingPlans(ctx, plan)
|
|
274
|
-
.then((result) => console.log(JSON.stringify(result, null, 2)))
|
|
275
|
-
.catch((e) => {
|
|
276
|
-
console.error(e.message);
|
|
277
|
-
process.exit(1);
|
|
278
|
-
});
|
|
279
|
-
}
|