@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,93 +0,0 @@
|
|
|
1
|
-
// One item as a framework-free store — the logic behind useItem: by `_id` or by a field match
|
|
2
|
-
// (slug routing), usable from React (useItem wraps it), from a static page's item view, from
|
|
3
|
-
// Vue/Svelte, or as the specification for a port.
|
|
4
|
-
//
|
|
5
|
-
// SSR-friendly: pass the server-fetched item as `initialItem` and start() fetches nothing.
|
|
6
|
-
// One store per item surface: createItemStore(), not a singleton.
|
|
7
|
-
import { getItemBy, getItemById } from "./items";
|
|
8
|
-
import type { CmsItem } from "./types";
|
|
9
|
-
|
|
10
|
-
/** Exactly one of `id` / `by`. */
|
|
11
|
-
export interface ItemRef {
|
|
12
|
-
id?: string;
|
|
13
|
-
by?: { field: string; value: string | number };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ItemStoreOptions {
|
|
17
|
-
collectionId: string;
|
|
18
|
-
ref: ItemRef;
|
|
19
|
-
initialItem?: CmsItem;
|
|
20
|
-
/** Reference field keys to inline as full items. */
|
|
21
|
-
include?: string[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ItemState {
|
|
25
|
-
/** null while loading OR when not found — branch on notFound for the miss state. */
|
|
26
|
-
item: CmsItem | null;
|
|
27
|
-
notFound: boolean;
|
|
28
|
-
error: string | null;
|
|
29
|
-
/** True until the fetch settles (false at once with an initialItem). */
|
|
30
|
-
loading: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface ItemStore {
|
|
34
|
-
getState(): ItemState;
|
|
35
|
-
subscribe(listener: () => void): () => void;
|
|
36
|
-
/** Fetch by ref when no `initialItem` was given. Call once when mounted. */
|
|
37
|
-
start(): void;
|
|
38
|
-
stop(): void;
|
|
39
|
-
/** Fetch again (after an error, or when the item may have changed). */
|
|
40
|
-
retry(): void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function createItemStore({ collectionId, ref, initialItem, include }: ItemStoreOptions): ItemStore {
|
|
44
|
-
let item: CmsItem | null = initialItem ?? null;
|
|
45
|
-
let notFound = false;
|
|
46
|
-
let error: string | null = null;
|
|
47
|
-
let loading = !initialItem;
|
|
48
|
-
let started = false;
|
|
49
|
-
let generation = 0;
|
|
50
|
-
const listeners = new Set<() => void>();
|
|
51
|
-
let snapshot: ItemState | null = null;
|
|
52
|
-
const emit = () => { snapshot = null; for (const fn of listeners) fn(); };
|
|
53
|
-
|
|
54
|
-
function getState(): ItemState {
|
|
55
|
-
if (snapshot) return snapshot;
|
|
56
|
-
snapshot = { item, notFound, error, loading };
|
|
57
|
-
return snapshot;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function load(): void {
|
|
61
|
-
const id = ++generation;
|
|
62
|
-
loading = true; error = null; emit();
|
|
63
|
-
const fetching = ref.id
|
|
64
|
-
? getItemById(collectionId, ref.id, { include })
|
|
65
|
-
: ref.by
|
|
66
|
-
? getItemBy(collectionId, ref.by.field, ref.by.value, { include })
|
|
67
|
-
: Promise.reject(new Error("useItem: pass ref.id or ref.by"));
|
|
68
|
-
fetching
|
|
69
|
-
.then((found) => {
|
|
70
|
-
if (generation !== id || !started) return;
|
|
71
|
-
item = found; notFound = found === null; loading = false;
|
|
72
|
-
emit();
|
|
73
|
-
})
|
|
74
|
-
.catch((e) => {
|
|
75
|
-
if (generation !== id || !started) return;
|
|
76
|
-
error = e instanceof Error ? e.message : String(e); loading = false;
|
|
77
|
-
emit();
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
getState,
|
|
83
|
-
subscribe(fn) { listeners.add(fn); return () => listeners.delete(fn); },
|
|
84
|
-
start() {
|
|
85
|
-
if (started) return;
|
|
86
|
-
started = true;
|
|
87
|
-
if (initialItem) return;
|
|
88
|
-
load();
|
|
89
|
-
},
|
|
90
|
-
stop() { started = false; generation++; },
|
|
91
|
-
retry() { if (started) load(); },
|
|
92
|
-
};
|
|
93
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// Wix Data rules and DTO mapping — transport-agnostic, imported by BOTH transports: ./items.ts
|
|
2
|
-
// (the SDK, managed Astro and React) and the REST twin in references/cms/rest/items.ts (fetch, a
|
|
3
|
-
// static site or a port to another language). Every rule about normalizing an item, validating a
|
|
4
|
-
// filter, and spelling a query for the wire lives HERE, once. A raw item may come from the SDK
|
|
5
|
-
// (dates as Date objects) or from REST (dates as `{ "$date": iso }`); the mappers accept both.
|
|
6
|
-
// Imports are type-only so a strip to JS emits no imports.
|
|
7
|
-
import type { CmsFilter, CmsItem, CmsPage, CmsQuery, CmsSort } from "./types";
|
|
8
|
-
|
|
9
|
-
/** A raw data item's payload as either transport returns it (fields flat, `_id` included). */
|
|
10
|
-
export type Raw = Record<string, any>;
|
|
11
|
-
/** Media value + size → https URL. Injected: the SDK transport scales through @wix/sdk, REST through the URL form. */
|
|
12
|
-
export type ImgSrc = (value: any, width: number, height: number) => string;
|
|
13
|
-
|
|
14
|
-
/** Page size when a query names none. */
|
|
15
|
-
export const DEFAULT_LIMIT = 20;
|
|
16
|
-
/** The size every IMAGE field is resolved at — one URL per item, large enough for a detail page. */
|
|
17
|
-
export const IMAGE_WIDTH = 1200;
|
|
18
|
-
export const IMAGE_HEIGHT = 900;
|
|
19
|
-
|
|
20
|
-
// ---- DTO normalization ---------------------------------------------------------------------------
|
|
21
|
-
|
|
22
|
-
/** REST spells DATE/DATETIME fields as `{ "$date": "<iso>" }`; the SDK decodes them into Date objects. */
|
|
23
|
-
function isDateWrapper(v: unknown): v is { $date: string } {
|
|
24
|
-
if (!v || typeof v !== "object" || Array.isArray(v)) return false;
|
|
25
|
-
const keys = Object.keys(v as Raw);
|
|
26
|
-
return keys.length === 1 && keys[0] === "$date" && typeof (v as Raw).$date === "string";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Raw → DTO value: dates become ISO strings (Date objects aren't serializable as island props;
|
|
31
|
-
* `{ $date }` wrappers aren't dates at all), IMAGE fields holding a `wix:image://` identifier
|
|
32
|
-
* become https URLs a browser can load. Recursive — included reference items too.
|
|
33
|
-
*/
|
|
34
|
-
export function toValue(v: unknown, imgSrc: ImgSrc): unknown {
|
|
35
|
-
if (v instanceof Date) return v.toISOString();
|
|
36
|
-
if (isDateWrapper(v)) {
|
|
37
|
-
// Same spelling as the SDK path (REST omits the milliseconds: "…T00:00:00Z").
|
|
38
|
-
const t = new Date(v.$date);
|
|
39
|
-
return Number.isNaN(t.getTime()) ? v.$date : t.toISOString();
|
|
40
|
-
}
|
|
41
|
-
if (typeof v === "string" && v.startsWith("wix:image://")) return imgSrc(v, IMAGE_WIDTH, IMAGE_HEIGHT);
|
|
42
|
-
if (Array.isArray(v)) return v.map((x) => toValue(x, imgSrc));
|
|
43
|
-
if (v && typeof v === "object") {
|
|
44
|
-
const out: Raw = {};
|
|
45
|
-
for (const [k, val] of Object.entries(v as Raw)) out[k] = toValue(val, imgSrc);
|
|
46
|
-
return out;
|
|
47
|
-
}
|
|
48
|
-
return v;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const toItem = (raw: Raw, imgSrc: ImgSrc): CmsItem => toValue(raw, imgSrc) as CmsItem;
|
|
52
|
-
|
|
53
|
-
export function toPage(items: Raw[], hasNext: boolean, total: number | null | undefined, imgSrc: ImgSrc): CmsPage {
|
|
54
|
-
return { items: items.map((r) => toItem(r, imgSrc)), hasNext, total: total ?? null };
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* A DATE/DATETIME field for display — the DTO carries an ISO string; this is the one place it
|
|
59
|
-
* becomes copy. "" for an absent or unparseable value (never "Invalid Date", never the raw ISO).
|
|
60
|
-
* formatDate(item.publishDate) → "August 20, 2026"
|
|
61
|
-
* formatDate(item.publishDate, "en-GB", { dateStyle: "medium" })
|
|
62
|
-
*/
|
|
63
|
-
export function formatDate(iso: unknown, locale = "en-US", options: Intl.DateTimeFormatOptions = { dateStyle: "long" }): string {
|
|
64
|
-
if (typeof iso !== "string" || !iso) return "";
|
|
65
|
-
const t = new Date(iso);
|
|
66
|
-
return Number.isNaN(t.getTime()) ? "" : new Intl.DateTimeFormat(locale, options).format(t);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ---- filter rules --------------------------------------------------------------------------------
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* An undefined comparand silently changes what a query matches (every row, or none) with no
|
|
73
|
-
* server error — the classic "my items shows everyone's items" bug. Throw at the call site;
|
|
74
|
-
* omit the filter entirely when you don't hold a value yet.
|
|
75
|
-
*/
|
|
76
|
-
export function assertFilterValue(f: CmsFilter): void {
|
|
77
|
-
if (f.op !== "isEmpty" && f.op !== "isNotEmpty" && f.value === undefined) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
`cms: filter on "${f.field}" (${f.op}) has an undefined value — pass a real value or omit the filter.`,
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// ---- the REST spelling of a query ---------------------------------------------------------------
|
|
85
|
-
// The SDK's query builder serializes these itself; the REST twin sends them literally. Proven live:
|
|
86
|
-
// a DATE comparand must travel as `{ "$date": iso }` (a plain ISO string compares as text and
|
|
87
|
-
// matches nothing); isEmpty is `{ field: null }` and isNotEmpty `{ field: { $ne: null } }` — the
|
|
88
|
-
// `$isEmpty` keyword is rejected (WDE0076).
|
|
89
|
-
|
|
90
|
-
/** A comparand on the wire: Date → `{ $date }`, arrays element-wise, everything else as-is. */
|
|
91
|
-
export function restValue(v: unknown): unknown {
|
|
92
|
-
if (v instanceof Date) return { $date: v.toISOString() };
|
|
93
|
-
if (Array.isArray(v)) return v.map(restValue);
|
|
94
|
-
return v;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const REST_OPS: Record<Exclude<CmsFilter["op"], "isEmpty" | "isNotEmpty">, string> = {
|
|
98
|
-
eq: "$eq",
|
|
99
|
-
ne: "$ne",
|
|
100
|
-
gt: "$gt",
|
|
101
|
-
ge: "$gte",
|
|
102
|
-
lt: "$lt",
|
|
103
|
-
le: "$lte",
|
|
104
|
-
contains: "$contains",
|
|
105
|
-
startsWith: "$startsWith",
|
|
106
|
-
hasSome: "$hasSome",
|
|
107
|
-
hasAll: "$hasAll",
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
/** One predicate → one filter object `{ field: condition }`. */
|
|
111
|
-
export function restCondition(f: CmsFilter): Raw {
|
|
112
|
-
assertFilterValue(f);
|
|
113
|
-
if (f.op === "isEmpty") return { [f.field]: null };
|
|
114
|
-
if (f.op === "isNotEmpty") return { [f.field]: { $ne: null } };
|
|
115
|
-
return { [f.field]: { [REST_OPS[f.op]]: restValue(f.value) } };
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** All predicates AND-ed: `{}` for none, the one object for one, `{ $and: [...] }` otherwise. */
|
|
119
|
-
export function restFilter(filters: CmsFilter[] = []): Raw {
|
|
120
|
-
const conditions = filters.map(restCondition);
|
|
121
|
-
if (conditions.length === 0) return {};
|
|
122
|
-
if (conditions.length === 1) return conditions[0];
|
|
123
|
-
return { $and: conditions };
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function restSort(sort: CmsSort[] = []): { fieldName: string; order: "ASC" | "DESC" }[] {
|
|
127
|
-
return sort.map((s) => ({ fieldName: s.field, order: s.direction === "desc" ? "DESC" : "ASC" }));
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* The full Query Data Items body. Offset paging (`skip` = page N × limit) so every page can carry
|
|
132
|
-
* its own filter/sort and `returnTotalCount` works; `includeReferences[].field` inlines reference
|
|
133
|
-
* items. POST /wix-data/v2/items/query
|
|
134
|
-
*/
|
|
135
|
-
export function queryBody(collectionId: string, query: CmsQuery = {}): Raw {
|
|
136
|
-
const { filters = [], sort = [], limit = DEFAULT_LIMIT, skip = 0, include = [], withTotal = false } = query;
|
|
137
|
-
return {
|
|
138
|
-
dataCollectionId: collectionId,
|
|
139
|
-
query: {
|
|
140
|
-
filter: restFilter(filters),
|
|
141
|
-
...(sort.length ? { sort: restSort(sort) } : {}),
|
|
142
|
-
paging: { limit, offset: skip },
|
|
143
|
-
},
|
|
144
|
-
...(include.length ? { includeReferences: include.map((field) => ({ field })) } : {}),
|
|
145
|
-
...(withTotal ? { returnTotalCount: true } : {}),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/** Whether another page follows — the response says so; the arithmetic is the fallback. */
|
|
150
|
-
export function restHasNext(pagingMetadata: Raw | undefined, offset: number, limit: number): boolean {
|
|
151
|
-
if (typeof pagingMetadata?.hasNext === "boolean") return pagingMetadata.hasNext;
|
|
152
|
-
if (typeof pagingMetadata?.total === "number") return offset + (pagingMetadata.count ?? 0) < pagingMetadata.total;
|
|
153
|
-
return (pagingMetadata?.count ?? 0) >= limit;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ---- the REST spelling of a write ---------------------------------------------------------------
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Field values for an insert/update body. A DATE field must arrive as `{ $date }` — JSON.stringify
|
|
160
|
-
* turns a Date into a plain ISO string, which Wix stores as TEXT and never matches a date query.
|
|
161
|
-
* The read-only system fields are Wix's to stamp, never sent.
|
|
162
|
-
*/
|
|
163
|
-
export function restWriteData(data: Record<string, unknown>): Raw {
|
|
164
|
-
const out: Raw = {};
|
|
165
|
-
for (const [k, v] of Object.entries(data)) {
|
|
166
|
-
if (k === "_createdDate" || k === "_updatedDate" || k === "_owner") continue;
|
|
167
|
-
out[k] = restValue(v);
|
|
168
|
-
}
|
|
169
|
-
return out;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** The Patch Data Item modifications for "set these fields" — one SET_FIELD per key. PATCH /wix-data/v2/items/{id} */
|
|
173
|
-
export function patchModifications(fields: Record<string, unknown>): Raw[] {
|
|
174
|
-
const entries = Object.entries(fields);
|
|
175
|
-
if (!entries.length) throw new Error("cms: patchItemFields called with no fields.");
|
|
176
|
-
return entries.map(([fieldPath, value]) => ({ fieldPath, action: "SET_FIELD", setFieldOptions: { value: restValue(value) } }));
|
|
177
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// Wix Data reads/writes (@wix/data `items`) over the SDK — the only file that touches raw data
|
|
2
|
-
// items on this transport. CMS is schema-generic: every function takes the collection id from the
|
|
3
|
-
// seed plan (seed/SEED.md) and returns plain CmsItem DTOs from ./types. The rules and mappers live
|
|
4
|
-
// in ./items-core (shared with the REST twin in references/cms/rest/); this file is the transport
|
|
5
|
-
// only. Copy as-is; extend by adding functions, not by editing these.
|
|
6
|
-
// docs: https://dev.wix.com/docs/sdk/business-solutions/data/items/query.md
|
|
7
|
-
// docs: https://dev.wix.com/docs/sdk/business-solutions/data/items/update.md
|
|
8
|
-
import { items as itemsModule } from "@wix/data";
|
|
9
|
-
import { wixModule } from "../sdk";
|
|
10
|
-
import { imgSrc } from "../media";
|
|
11
|
-
import { DEFAULT_LIMIT, assertFilterValue, toItem, type Raw } from "./items-core";
|
|
12
|
-
import type { CmsFilter, CmsItem, CmsPage, CmsQuery } from "./types";
|
|
13
|
-
|
|
14
|
-
const items = wixModule(itemsModule);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Query one page of a collection. An empty result on a PUBLIC collection is a seed
|
|
18
|
-
* permissions bug (read must be "ANYONE"), not a query bug — never reach for auth.elevate.
|
|
19
|
-
*/
|
|
20
|
-
export async function queryItems(collectionId: string, query: CmsQuery = {}): Promise<CmsPage> {
|
|
21
|
-
const { filters = [], sort = [], limit = DEFAULT_LIMIT, skip = 0, include = [], withTotal = false } = query;
|
|
22
|
-
let q = items.query(collectionId);
|
|
23
|
-
for (const f of filters) {
|
|
24
|
-
assertFilterValue(f);
|
|
25
|
-
const v = f.value as any;
|
|
26
|
-
switch (f.op) {
|
|
27
|
-
case "eq": q = q.eq(f.field, v); break;
|
|
28
|
-
case "ne": q = q.ne(f.field, v); break;
|
|
29
|
-
case "gt": q = q.gt(f.field, v); break;
|
|
30
|
-
case "ge": q = q.ge(f.field, v); break;
|
|
31
|
-
case "lt": q = q.lt(f.field, v); break;
|
|
32
|
-
case "le": q = q.le(f.field, v); break;
|
|
33
|
-
case "contains": q = q.contains(f.field, v); break;
|
|
34
|
-
case "startsWith": q = q.startsWith(f.field, v); break;
|
|
35
|
-
case "hasSome": q = q.hasSome(f.field, v); break;
|
|
36
|
-
case "hasAll": q = q.hasAll(f.field, v); break;
|
|
37
|
-
case "isEmpty": q = q.isEmpty(f.field); break;
|
|
38
|
-
case "isNotEmpty": q = q.isNotEmpty(f.field); break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
for (const s of sort) q = s.direction === "desc" ? q.descending(s.field) : q.ascending(s.field);
|
|
42
|
-
if (include.length) q = q.include(...include);
|
|
43
|
-
const res = await q.limit(limit).skip(skip).find(withTotal ? { returnTotalCount: true } : undefined);
|
|
44
|
-
return {
|
|
45
|
-
items: (res.items ?? []).map((r: Raw) => toItem(r, imgSrc)),
|
|
46
|
-
hasNext: res.hasNext(),
|
|
47
|
-
total: res.totalCount ?? null,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Fetch one item by `_id`. Null when not found. */
|
|
52
|
-
export async function getItemById(
|
|
53
|
-
collectionId: string,
|
|
54
|
-
itemId: string,
|
|
55
|
-
{ include = [] }: { include?: string[] } = {},
|
|
56
|
-
): Promise<CmsItem | null> {
|
|
57
|
-
const raw = await items.get(collectionId, itemId, {
|
|
58
|
-
...(include.length ? { includeReferences: include.map((field) => ({ field })) } : {}),
|
|
59
|
-
});
|
|
60
|
-
return raw ? toItem(raw as Raw, imgSrc) : null;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Fetch the first item whose `field` equals `value` — slug-style routing (Wix Data has no
|
|
65
|
-
* native get-by-slug). Null when not found → render a not-found state, never invent an item.
|
|
66
|
-
*/
|
|
67
|
-
export async function getItemBy(
|
|
68
|
-
collectionId: string,
|
|
69
|
-
field: string,
|
|
70
|
-
value: string | number,
|
|
71
|
-
{ include = [] }: { include?: string[] } = {},
|
|
72
|
-
): Promise<CmsItem | null> {
|
|
73
|
-
const page = await queryItems(collectionId, { filters: [{ field, op: "eq", value }], limit: 1, include });
|
|
74
|
-
return page.items[0] ?? null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/** Count items matching the filters — empty-state logic and result counts. */
|
|
78
|
-
export async function countItems(collectionId: string, filters: CmsFilter[] = []): Promise<number> {
|
|
79
|
-
const page = await queryItems(collectionId, { filters, limit: 1, withTotal: true });
|
|
80
|
-
return page.total ?? page.items.length;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Insert an item (visitor form / member submission). Succeeds only when the collection's
|
|
85
|
-
* insert permission covers the caller (403 otherwise — a seed permissions step, not a code
|
|
86
|
-
* bug). Never set `_owner` — Wix stamps it from the caller's identity.
|
|
87
|
-
* Date fields must be Date objects (an ISO string is stored as text and breaks date queries).
|
|
88
|
-
*/
|
|
89
|
-
export async function insertItem(collectionId: string, data: Record<string, unknown>): Promise<CmsItem> {
|
|
90
|
-
const created = await items.insert(collectionId, data as Raw);
|
|
91
|
-
return toItem(created as Raw, imgSrc);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* REPLACE an item — fields omitted from `item` are WIPED (update does not patch). Spread the
|
|
96
|
-
* full item you hold and override; for an id + a few changed fields use patchItemFields.
|
|
97
|
-
* A round-tripped DTO carries dates as ISO strings — wrap each date field back
|
|
98
|
-
* (`new Date(iso)`) before updating, or the DATE field is silently rewritten as text.
|
|
99
|
-
*/
|
|
100
|
-
export async function updateItem(collectionId: string, item: CmsItem): Promise<CmsItem> {
|
|
101
|
-
const updated = await items.update(collectionId, item as Raw & { _id: string });
|
|
102
|
-
return toItem(updated as Raw, imgSrc);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/** Patch only the named fields — the safe partial change (no replace-wipes-fields footgun). */
|
|
106
|
-
export async function patchItemFields(
|
|
107
|
-
collectionId: string,
|
|
108
|
-
itemId: string,
|
|
109
|
-
fields: Record<string, unknown>,
|
|
110
|
-
): Promise<CmsItem> {
|
|
111
|
-
const entries = Object.entries(fields);
|
|
112
|
-
if (!entries.length) throw new Error("cms: patchItemFields called with no fields.");
|
|
113
|
-
let p = items.patch(collectionId, itemId);
|
|
114
|
-
for (const [k, v] of entries) p = p.setField(k, v);
|
|
115
|
-
const patched = await p.run();
|
|
116
|
-
return toItem(patched as Raw, imgSrc);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** Remove an item by `_id`. Irreversible. Returns the removed item (null if it didn't exist). */
|
|
120
|
-
export async function removeItem(collectionId: string, itemId: string): Promise<CmsItem | null> {
|
|
121
|
-
const removed = await items.remove(collectionId, itemId);
|
|
122
|
-
return removed ? toItem(removed as Raw, imgSrc) : null;
|
|
123
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
// CMS DTOs — the serializable shapes every hook, component, and page consumes. CMS is
|
|
2
|
-
// schema-generic: field keys come from the seed plan (seed/SEED.md), so an item is a flat
|
|
3
|
-
// field map rather than a fixed interface. Plain JSON: safe as Astro island props or across
|
|
4
|
-
// server/client boundaries. By the time an item leaves the data layer, Date fields are ISO
|
|
5
|
-
// strings and IMAGE fields are resolved https URLs.
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* One collection item: `_id` plus the collection's fields, flat on the item (there is no
|
|
9
|
-
* `item.data.*` — that is the REST shape and reads undefined here).
|
|
10
|
-
* Field values by type: TEXT/URL/EMAIL → string, NUMBER → number, BOOLEAN → boolean,
|
|
11
|
-
* DATE/DATETIME → ISO string, IMAGE → https URL ("" never happens — absent fields are
|
|
12
|
-
* undefined), RICH_TEXT → the stored HTML string, REFERENCE/MULTI_REFERENCE → id(s), or
|
|
13
|
-
* full CmsItem(s) when the query included the field.
|
|
14
|
-
*/
|
|
15
|
-
export interface CmsItem {
|
|
16
|
-
_id: string;
|
|
17
|
-
/** ISO string (the SDK's Date objects are serialized by the data layer). */
|
|
18
|
-
_createdDate?: string;
|
|
19
|
-
_updatedDate?: string;
|
|
20
|
-
/** Id of the member who created the row (member-scoped collections). */
|
|
21
|
-
_owner?: string;
|
|
22
|
-
[key: string]: unknown;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type CmsFilterOp =
|
|
26
|
-
| "eq"
|
|
27
|
-
| "ne"
|
|
28
|
-
| "gt"
|
|
29
|
-
| "ge"
|
|
30
|
-
| "lt"
|
|
31
|
-
| "le"
|
|
32
|
-
| "contains"
|
|
33
|
-
| "startsWith"
|
|
34
|
-
| "hasSome"
|
|
35
|
-
| "hasAll"
|
|
36
|
-
| "isEmpty"
|
|
37
|
-
| "isNotEmpty";
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* One query predicate. Comparands must match the field's stored type — a DATE/DATETIME
|
|
41
|
-
* field only matches a Date object (an ISO string compares as text and matches nothing).
|
|
42
|
-
*/
|
|
43
|
-
export interface CmsFilter {
|
|
44
|
-
field: string;
|
|
45
|
-
op: CmsFilterOp;
|
|
46
|
-
/** Required except for isEmpty/isNotEmpty; hasSome/hasAll take an array. */
|
|
47
|
-
value?: string | number | boolean | Date | (string | number | Date)[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface CmsSort {
|
|
51
|
-
field: string;
|
|
52
|
-
/** Default "asc". */
|
|
53
|
-
direction?: "asc" | "desc";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface CmsQuery {
|
|
57
|
-
filters?: CmsFilter[];
|
|
58
|
-
sort?: CmsSort[];
|
|
59
|
-
/** Page size (default 20). */
|
|
60
|
-
limit?: number;
|
|
61
|
-
/** Items to skip — page N is skip = N * limit. */
|
|
62
|
-
skip?: number;
|
|
63
|
-
/** Reference field keys to inline as full items (otherwise the field holds ids). */
|
|
64
|
-
include?: string[];
|
|
65
|
-
/** true → the page carries `total` (slower query; for counts/empty-state logic). */
|
|
66
|
-
withTotal?: boolean;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** One page of items. Load the next page with skip = items shown so far. */
|
|
70
|
-
export interface CmsPage {
|
|
71
|
-
items: CmsItem[];
|
|
72
|
-
hasNext: boolean;
|
|
73
|
-
/** Total matching items — only when the query asked `withTotal`, else null. */
|
|
74
|
-
total: number | null;
|
|
75
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
// The site chrome for every CMS page — THIS file (header/footer/nav) plus the @theme token
|
|
3
|
-
// block in src/styles/global.css are what you brand. Keep the <slot name="seo-tags" /> in
|
|
4
|
-
// <head> and the global.css import. Add one nav link per content surface you build (the
|
|
5
|
-
// routes are yours — CMS ships no fixed pages). (If another vertical is also deployed, its
|
|
6
|
-
// SiteLayout won; merge nav links there instead.)
|
|
7
|
-
import "../styles/global.css";
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
title: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
}
|
|
13
|
-
const { title, description } = Astro.props;
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
<!doctype html>
|
|
17
|
-
<html lang="en">
|
|
18
|
-
<head>
|
|
19
|
-
<meta charset="UTF-8" />
|
|
20
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
21
|
-
<title>{title}</title>
|
|
22
|
-
{description && <meta name="description" content={description} />}
|
|
23
|
-
<slot name="seo-tags" />
|
|
24
|
-
</head>
|
|
25
|
-
<body>
|
|
26
|
-
<header class="sticky top-0 z-40 border-b border-border bg-background/80 backdrop-blur">
|
|
27
|
-
<div class="mx-auto flex h-16 max-w-6xl items-center justify-between px-6">
|
|
28
|
-
<a href="/" class="text-base font-bold tracking-tight text-foreground no-underline">Brand Name</a>
|
|
29
|
-
<nav class="flex items-center gap-6 text-sm">
|
|
30
|
-
<!-- one link per content surface you build, e.g. <a href="/recipes">Recipes</a> -->
|
|
31
|
-
</nav>
|
|
32
|
-
</div>
|
|
33
|
-
</header>
|
|
34
|
-
<main class="mx-auto max-w-6xl px-6 pb-24 pt-10">
|
|
35
|
-
<slot />
|
|
36
|
-
</main>
|
|
37
|
-
<footer class="border-t border-border px-6 py-10 text-center text-sm text-muted-foreground">
|
|
38
|
-
© Brand Name
|
|
39
|
-
</footer>
|
|
40
|
-
</body>
|
|
41
|
-
</html>
|