@wix/agent-skills 1.14.0 → 1.15.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/README.md +4 -1
- package/package.json +1 -1
- package/skills/README.md +23 -0
- package/skills/wix-app/SKILL.md +10 -2
- package/skills/wix-app/references/AUTO_PATTERNS_DASHBOARD.md +326 -0
- package/skills/wix-app/references/CODE_QUALITY.md +1 -0
- package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +124 -115
- package/skills/wix-app/references/DASHBOARD_PAGE.md +3 -0
- package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +23 -9
- package/skills/wix-app/references/SITE_PLUGIN.md +1 -1
- package/skills/wix-app/references/auto-patterns-dashboard/action-cell.md +115 -0
- package/skills/wix-app/references/auto-patterns-dashboard/app-config-structure.md +264 -0
- package/skills/wix-app/references/auto-patterns-dashboard/app-context.md +37 -0
- package/skills/wix-app/references/auto-patterns-dashboard/bulk-actions.md +86 -0
- package/skills/wix-app/references/auto-patterns-dashboard/collection-page-actions.md +119 -0
- package/skills/wix-app/references/auto-patterns-dashboard/collection-page.md +103 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-actions-override.md +76 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-columns-override.md +82 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-components-override.md +89 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-header-override.md +124 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-sections-override.md +91 -0
- package/skills/wix-app/references/auto-patterns-dashboard/custom-slots-override.md +71 -0
- package/skills/wix-app/references/auto-patterns-dashboard/entity-page-actions.md +70 -0
- package/skills/wix-app/references/auto-patterns-dashboard/entity-page-view-actions.md +73 -0
- package/skills/wix-app/references/auto-patterns-dashboard/entity-page.md +98 -0
- package/skills/wix-app/references/auto-patterns-dashboard/example-patterns.json +278 -0
- package/skills/wix-app/references/auto-patterns-dashboard/pages-configuration.md +94 -0
- package/skills/wix-app/references/auto-patterns-dashboard/resolved-action.md +43 -0
- package/skills/wix-app/references/auto-patterns-dashboard/sdk-utilities.md +66 -0
- package/skills/wix-app/references/auto-patterns-dashboard/views.md +76 -0
- package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +1 -14
- package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +54 -29
- package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +2 -2
- package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +17 -105
- package/skills/wix-app/references/editor-react-component/DESIGN-STATES.md +127 -0
- package/skills/wix-app/references/editor-react-component/PARTS.md +2 -1
- package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +15 -15
- package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +25 -53
- package/skills/wix-app/scripts/generate-auto-patterns.js +510 -0
- package/skills/wix-auth/SKILL.md +12 -0
- package/skills/wix-auth/references/device-flow.md +140 -0
- package/skills/wix-docs/SKILL.md +188 -0
- package/skills/wix-docs/references/API_SPEC_SEARCH.md +213 -0
- package/skills/wix-docs/references/EXTRACTING.md +120 -0
- package/skills/wix-headless/SKILL.md +84 -130
- package/skills/wix-headless/entry/bootstrap.mjs +93 -0
- package/skills/wix-headless/entry/skill.md +78 -0
- package/skills/wix-headless/references/AI_FEATURES.md +178 -0
- package/skills/wix-headless/references/CAPABILITIES.md +84 -0
- package/skills/wix-headless/references/DISCOVERY.md +34 -56
- package/skills/wix-headless/references/DOC_DISCOVERY.md +37 -0
- package/skills/wix-headless/references/FEEDBACK.md +118 -0
- package/skills/wix-headless/references/IMAGE_GENERATION.md +69 -0
- package/skills/wix-headless/references/SDK_HANDOFF.md +97 -0
- package/skills/wix-headless/references/SEED.md +44 -188
- package/skills/wix-headless/references/SETUP.md +32 -103
- package/skills/wix-headless/references/astro.md +98 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-a-blog.md +196 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-a-store.md +236 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-bookings.md +279 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-cms.md +163 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-events.md +203 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-forms.md +222 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-astro.md +124 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-custom-login.md +160 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-members-non-astro.md +118 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-portfolio.md +132 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-pricing-plans.md +124 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-restaurant-orders.md +188 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-restaurant-reservations.md +173 -0
- package/skills/wix-headless/references/inline-recipes/how-to-code-restaurants.md +161 -0
- package/skills/wix-headless/references/inline-recipes/setup-blog.md +175 -0
- package/skills/wix-headless/references/inline-recipes/setup-bookings.md +228 -0
- package/skills/wix-headless/references/inline-recipes/setup-cms.md +200 -0
- package/skills/wix-headless/references/inline-recipes/setup-events.md +196 -0
- package/skills/wix-headless/references/inline-recipes/setup-forms.md +174 -0
- package/skills/wix-headless/references/inline-recipes/setup-online-store.md +176 -0
- package/skills/wix-headless/references/inline-recipes/setup-portfolio.md +153 -0
- package/skills/wix-headless/references/inline-recipes/setup-pricing-plans.md +229 -0
- package/skills/wix-headless/references/inline-recipes/setup-restaurant-orders.md +161 -0
- package/skills/wix-headless/references/inline-recipes/setup-restaurant-reservations.md +117 -0
- package/skills/wix-headless/references/inline-recipes/setup-restaurants.md +152 -0
- package/skills/wix-headless/references/managed/AUTHENTICATION.md +57 -0
- package/skills/wix-headless/references/managed/CONNECT.md +74 -0
- package/skills/wix-headless/references/managed/CREATE.md +130 -0
- package/skills/wix-headless/references/managed/DEPLOYMENT.md +57 -0
- package/skills/wix-headless/references/non-astro.md +59 -0
- package/skills/wix-headless/references/self-managed/AUTHENTICATION.md +22 -0
- package/skills/wix-headless/references/self-managed/DEPLOYMENT.md +7 -0
- package/skills/wix-headless/references/stripe/AUTHENTICATION.md +55 -0
- package/skills/wix-headless/references/stripe/DEPLOYMENT.md +63 -0
- package/skills/wix-manage/SKILL.md +24 -1
- package/skills/wix-manage/references/analytics/query-site-analytics.md +241 -0
- package/skills/wix-manage/references/bookings/create-and-update-booking-services.md +1 -1
- package/skills/wix-manage/references/bookings/diagnose-availability-issues.md +265 -0
- package/skills/wix-manage/references/marketing/create-and-publish-social-post.md +436 -0
- package/skills/wix-manage/references/marketing/generate-and-publish-marketing-plan.md +209 -0
- package/skills/wix-manage/references/rich-content/author-ricos-rich-content.md +249 -0
- package/skills/wix-manage/references/stores/create-product-with-options-catalog-v3.md +51 -0
- package/skills/wix-vibe-headless/SKILL.md +136 -0
- package/skills/wix-vibe-headless/references/blog/INSTRUCTIONS.md +128 -0
- package/skills/wix-vibe-headless/references/blog/wix-blog.js +217 -0
- package/skills/wix-vibe-headless/references/bookings/INSTRUCTIONS.md +153 -0
- package/skills/wix-vibe-headless/references/bookings/wix-bookings-checkout.js +147 -0
- package/skills/wix-vibe-headless/references/bookings/wix-bookings-services.js +215 -0
- package/skills/wix-vibe-headless/references/cms/INSTRUCTIONS.md +154 -0
- package/skills/wix-vibe-headless/references/cms/wix-cms.js +186 -0
- package/skills/wix-vibe-headless/references/events/INSTRUCTIONS.md +142 -0
- package/skills/wix-vibe-headless/references/events/wix-events-browse.js +135 -0
- package/skills/wix-vibe-headless/references/events/wix-events-registration.js +187 -0
- package/skills/wix-vibe-headless/references/members/INSTRUCTIONS.md +211 -0
- package/skills/wix-vibe-headless/references/members/wix-members-auth.js +387 -0
- package/skills/wix-vibe-headless/references/portfolio/INSTRUCTIONS.md +111 -0
- package/skills/wix-vibe-headless/references/portfolio/wix-portfolio.js +194 -0
- package/skills/wix-vibe-headless/references/pricing-plans/INSTRUCTIONS.md +127 -0
- package/skills/wix-vibe-headless/references/pricing-plans/wix-pricing-plans.js +157 -0
- package/skills/wix-vibe-headless/references/restaurants/INSTRUCTIONS.md +138 -0
- package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-menu.js +224 -0
- package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-ordering.js +156 -0
- package/skills/wix-vibe-headless/references/restaurants/wix-restaurants-reservations.js +107 -0
- package/skills/wix-vibe-headless/references/shared/wix-client.js +186 -0
- package/skills/wix-vibe-headless/references/storefront/INSTRUCTIONS.md +155 -0
- package/skills/wix-vibe-headless/references/storefront/wix-store-cart.js +147 -0
- package/skills/wix-vibe-headless/references/storefront/wix-store-catalog.js +142 -0
- package/skills/wix-headless/references/BUILD-astro.md +0 -253
- package/skills/wix-headless/references/BUILD-own-build.md +0 -167
- package/skills/wix-headless/references/BUILD.md +0 -105
- package/skills/wix-headless/references/DESIGN_SYSTEM.md +0 -165
- package/skills/wix-headless/references/DISCOVERY-connect.md +0 -55
- package/skills/wix-headless/references/DISCOVERY-create.md +0 -238
- package/skills/wix-headless/references/PLAN-connect.md +0 -19
- package/skills/wix-headless/references/PLAN-create.md +0 -17
- package/skills/wix-headless/references/PLAN.md +0 -92
- package/skills/wix-headless/references/astro/blog/BLOG_PAGES.md +0 -300
- package/skills/wix-headless/references/astro/blog/BLOG_SETUP.md +0 -218
- package/skills/wix-headless/references/astro/bookings/COMPONENTS.md +0 -45
- package/skills/wix-headless/references/astro/bookings/SERVICES_PAGES.md +0 -77
- package/skills/wix-headless/references/astro/cms/CMS_FOUNDATIONS.md +0 -214
- package/skills/wix-headless/references/astro/cms/FAQ_KNOWLEDGE_BASE.md +0 -231
- package/skills/wix-headless/references/astro/cms/PORTFOLIO.md +0 -453
- package/skills/wix-headless/references/astro/cms/RESOURCE_LIBRARY.md +0 -354
- package/skills/wix-headless/references/astro/cms/TEAM_DIRECTORY.md +0 -299
- package/skills/wix-headless/references/astro/designer/INSTRUCTIONS.md +0 -351
- package/skills/wix-headless/references/astro/ecom/CART_PAGES.md +0 -119
- package/skills/wix-headless/references/astro/ecom/CART_WIRING.md +0 -103
- package/skills/wix-headless/references/astro/ecom/COMPONENTS_CSS.md +0 -132
- package/skills/wix-headless/references/astro/forms/CONTACT_FORM.md +0 -463
- package/skills/wix-headless/references/astro/gift-cards/COMPONENTS.md +0 -119
- package/skills/wix-headless/references/astro/gift-cards/PAGES.md +0 -129
- package/skills/wix-headless/references/astro/stores/BACK_IN_STOCK.md +0 -178
- package/skills/wix-headless/references/astro/stores/CATEGORY_PAGES.md +0 -85
- package/skills/wix-headless/references/astro/stores/COMPONENTS_CSS.md +0 -129
- package/skills/wix-headless/references/astro/stores/HOME_AND_NAV.md +0 -229
- package/skills/wix-headless/references/astro/stores/PRODUCT_PAGES.md +0 -215
- package/skills/wix-headless/references/astro/stores/SHARED_WIRING.md +0 -165
- package/skills/wix-headless/references/astro/templates/Layout.astro +0 -132
- package/skills/wix-headless/references/astro/templates/astro.config.mjs +0 -41
- package/skills/wix-headless/references/astro/templates/bookings/AvailabilityCalendar.tsx +0 -374
- package/skills/wix-headless/references/astro/templates/bookings/BookingForm.tsx +0 -136
- package/skills/wix-headless/references/astro/templates/bookings/SeoTags.astro +0 -25
- package/skills/wix-headless/references/astro/templates/bookings/ServiceBookingFlow.tsx +0 -71
- package/skills/wix-headless/references/astro/templates/bookings/ServiceCard.astro +0 -54
- package/skills/wix-headless/references/astro/templates/bookings/booking-confirmation.astro +0 -49
- package/skills/wix-headless/references/astro/templates/bookings/bookingDriver.ts +0 -245
- package/skills/wix-headless/references/astro/templates/bookings/components-bookings.css +0 -424
- package/skills/wix-headless/references/astro/templates/bookings/services/[slug].astro +0 -176
- package/skills/wix-headless/references/astro/templates/bookings/services/index.astro +0 -181
- package/skills/wix-headless/references/astro/templates/ecom/CartBadge.tsx +0 -84
- package/skills/wix-headless/references/astro/templates/ecom/CartView.tsx +0 -543
- package/skills/wix-headless/references/astro/templates/ecom/cart.astro +0 -13
- package/skills/wix-headless/references/astro/templates/ecom/components-ecom.css +0 -302
- package/skills/wix-headless/references/astro/templates/ecom/discounts.ts +0 -71
- package/skills/wix-headless/references/astro/templates/ecom/thank-you.astro +0 -24
- package/skills/wix-headless/references/astro/templates/gift-cards/GiftCardPurchase.tsx +0 -172
- package/skills/wix-headless/references/astro/templates/gift-cards/_home-teaser-snippet.astro +0 -42
- package/skills/wix-headless/references/astro/templates/gift-cards/_nav-snippet.astro +0 -11
- package/skills/wix-headless/references/astro/templates/gift-cards/components-gift-cards.css +0 -220
- package/skills/wix-headless/references/astro/templates/gift-cards/gift-cards.astro +0 -51
- package/skills/wix-headless/references/astro/templates/gift-cards/gift-cards.ts +0 -75
- package/skills/wix-headless/references/astro/templates/global.css +0 -288
- package/skills/wix-headless/references/astro/templates/stores/AddToCartButton.tsx +0 -77
- package/skills/wix-headless/references/astro/templates/stores/BackInStockForm.tsx +0 -176
- package/skills/wix-headless/references/astro/templates/stores/CategoryRail.astro +0 -69
- package/skills/wix-headless/references/astro/templates/stores/ProductCard.astro +0 -79
- package/skills/wix-headless/references/astro/templates/stores/ProductPurchase.tsx +0 -397
- package/skills/wix-headless/references/astro/templates/stores/SeoTags.astro +0 -21
- package/skills/wix-headless/references/astro/templates/stores/back-in-stock.ts +0 -67
- package/skills/wix-headless/references/astro/templates/stores/categories.ts +0 -155
- package/skills/wix-headless/references/astro/templates/stores/category/[slug].astro +0 -130
- package/skills/wix-headless/references/astro/templates/stores/components-stores.css +0 -400
- package/skills/wix-headless/references/astro/templates/stores/products/[slug].astro +0 -128
- package/skills/wix-headless/references/astro/templates/stores/products/index.astro +0 -101
- package/skills/wix-headless/references/blog/BLOG_CONTENT.md +0 -161
- package/skills/wix-headless/references/blog/INSTRUCTIONS.md +0 -32
- package/skills/wix-headless/references/bookings/FLOW.md +0 -246
- package/skills/wix-headless/references/bookings/INSTRUCTIONS.md +0 -95
- package/skills/wix-headless/references/bookings/SERVICES_DATA.md +0 -355
- package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +0 -176
- package/skills/wix-headless/references/cms/INSTRUCTIONS.md +0 -71
- package/skills/wix-headless/references/commands/known-apps.json +0 -6
- package/skills/wix-headless/references/custom/CONNECTION_PLAN.md +0 -142
- package/skills/wix-headless/references/custom/INSTRUCTIONS.md +0 -88
- package/skills/wix-headless/references/custom/blog/WIRING.md +0 -52
- package/skills/wix-headless/references/custom/bookings/WIRING.md +0 -197
- package/skills/wix-headless/references/custom/cms/WIRING.md +0 -97
- package/skills/wix-headless/references/custom/ecom/WIRING.md +0 -67
- package/skills/wix-headless/references/custom/forms/WIRING.md +0 -101
- package/skills/wix-headless/references/custom/stores/WIRING.md +0 -80
- package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +0 -59
- package/skills/wix-headless/references/forms/INSTRUCTIONS.md +0 -43
- package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +0 -51
- package/skills/wix-headless/references/images/INSTRUCTIONS.md +0 -357
- package/skills/wix-headless/references/seed-recipes.md +0 -49
- package/skills/wix-headless/references/shared/AGENTS_MD.md +0 -47
- package/skills/wix-headless/references/shared/AUTHENTICATION.md +0 -108
- package/skills/wix-headless/references/shared/BUILD_NOISE.md +0 -8
- package/skills/wix-headless/references/shared/DESIGN_MD.md +0 -84
- package/skills/wix-headless/references/shared/DOCS_SEARCH.md +0 -41
- package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +0 -186
- package/skills/wix-headless/references/shared/IMPLEMENTER.md +0 -206
- package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +0 -97
- package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +0 -143
- package/skills/wix-headless/references/shared/STYLING.md +0 -140
- package/skills/wix-headless/references/stores/INSTRUCTIONS.md +0 -126
- package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +0 -252
- package/skills/wix-headless/references/verticals/_schema.json +0 -74
- package/skills/wix-headless/references/verticals/_schema.md +0 -95
- package/skills/wix-headless/references/verticals/blog.md +0 -31
- package/skills/wix-headless/references/verticals/bookings.md +0 -41
- package/skills/wix-headless/references/verticals/cms.md +0 -30
- package/skills/wix-headless/references/verticals/ecom.md +0 -25
- package/skills/wix-headless/references/verticals/forms.md +0 -26
- package/skills/wix-headless/references/verticals/gift-cards.md +0 -24
- package/skills/wix-headless/references/verticals/stores.md +0 -33
- package/skills/wix-headless/scripts/check-manifest.mjs +0 -335
- package/skills/wix-headless/scripts/compose.mjs +0 -520
- package/skills/wix-headless/scripts/emit-design-tokens.mjs +0 -157
- package/skills/wix-headless/scripts/flatten.sh +0 -61
- package/skills/wix-headless/scripts/generate-images.mjs +0 -242
- package/skills/wix-headless/scripts/patch-decorative-slots.mjs +0 -154
- package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +0 -190
- package/skills/wix-headless/scripts/scaffold.sh +0 -139
- package/skills/wix-headless/scripts/seed-utilities.sh +0 -93
- package/skills/wix-headless/scripts/write-decorative-json.mjs +0 -62
- package/skills/wix-headless/shared-utilities/analytics.ts +0 -40
- package/skills/wix-headless/shared-utilities/ricos.ts +0 -179
- package/skills/wix-headless/shared-utilities/wix-image.ts +0 -72
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Build a deterministic execution plan for Image Phase 2 from a slim image
|
|
3
|
-
// agent's prompt array + the orchestrator's per-product / per-cms-item GETs.
|
|
4
|
-
//
|
|
5
|
-
// The slim image agent's only job is to return a list of brand-aligned prompts
|
|
6
|
-
// (one per entity). This script transforms that list (plus the entity details
|
|
7
|
-
// the orchestrator pre-fetched) into a structured plan the orchestrator can
|
|
8
|
-
// execute as a sequence of concurrent batches:
|
|
9
|
-
//
|
|
10
|
-
// waves — Runware generation requests, grouped into waves of <waveSize>
|
|
11
|
-
// (default 3) to match the google:4@2 throttle. Each wave is
|
|
12
|
-
// one orchestration step with N parallel curls in one shell,
|
|
13
|
-
// backgrounded with `&`; each curl sends one task in the body array.
|
|
14
|
-
//
|
|
15
|
-
// imports — POST /site-media/v1/files/import requests, one per generated
|
|
16
|
-
// image. Indexed by taskUUID so the orchestrator threads the
|
|
17
|
-
// wave-result URL through to the import body.
|
|
18
|
-
//
|
|
19
|
-
// patches — Per-entity-type write requests (PATCH for products & blog
|
|
20
|
-
// posts; PUT for CMS items). Bodies use placeholders the
|
|
21
|
-
// orchestrator substitutes with import results:
|
|
22
|
-
// __IMAGE_URL__ — the full wixstatic URL (file.url)
|
|
23
|
-
// __IMAGE_FILE_ID__ — the file ID (file.fileUrl)
|
|
24
|
-
//
|
|
25
|
-
// publishes — Re-publish calls for blog posts ONLY (PATCHing a published
|
|
26
|
-
// draft un-publishes it). One per blog-post entity.
|
|
27
|
-
//
|
|
28
|
-
// Usage:
|
|
29
|
-
// echo "$INPUT_JSON" | node plan-entity-image-waves.mjs
|
|
30
|
-
//
|
|
31
|
-
// The script is pure data transformation — no I/O beyond stdin / stdout, no
|
|
32
|
-
// MCP, no network. The encoded knowledge is the per-entity-type body shapes
|
|
33
|
-
// (frozen from references/images/INSTRUCTIONS.md so a single source of truth).
|
|
34
|
-
|
|
35
|
-
import { readFileSync } from "node:fs";
|
|
36
|
-
|
|
37
|
-
// Body shape constants — keep aligned with references/images/INSTRUCTIONS.md.
|
|
38
|
-
const RUNWARE_DEFAULTS = {
|
|
39
|
-
taskType: "imageInference",
|
|
40
|
-
outputType: "URL",
|
|
41
|
-
outputFormat: "PNG",
|
|
42
|
-
model: "google:4@2",
|
|
43
|
-
numberResults: 1,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const DEFAULT_WAVE_SIZE = 3;
|
|
47
|
-
|
|
48
|
-
let input;
|
|
49
|
-
try {
|
|
50
|
-
input = JSON.parse(readFileSync(0, "utf8"));
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.error(`plan-entity-image-waves: stdin is not valid JSON (${e.message})`);
|
|
53
|
-
process.exit(2);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const prompts = Array.isArray(input.prompts) ? input.prompts : [];
|
|
57
|
-
if (prompts.length === 0) {
|
|
58
|
-
console.error("plan-entity-image-waves: no prompts in input — nothing to plan");
|
|
59
|
-
process.exit(2);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const productDetails = input.productDetails ?? {};
|
|
63
|
-
const cmsDetails = input.cmsDetails ?? {};
|
|
64
|
-
const waveSize = Math.max(1, Math.min(input.waveSize ?? DEFAULT_WAVE_SIZE, 8));
|
|
65
|
-
const model = input.model ?? RUNWARE_DEFAULTS.model;
|
|
66
|
-
|
|
67
|
-
// ---- 1. Runware waves (gen-side parallelism, throttle-bucketed) -----------
|
|
68
|
-
const waves = [];
|
|
69
|
-
for (let i = 0; i < prompts.length; i += waveSize) {
|
|
70
|
-
const slice = prompts.slice(i, i + waveSize);
|
|
71
|
-
waves.push(slice.map((p) => ({
|
|
72
|
-
taskUUID: p.taskUUID,
|
|
73
|
-
body: [{
|
|
74
|
-
...RUNWARE_DEFAULTS,
|
|
75
|
-
model,
|
|
76
|
-
taskUUID: p.taskUUID,
|
|
77
|
-
positivePrompt: p.positivePrompt,
|
|
78
|
-
width: p.width ?? 1024,
|
|
79
|
-
height: p.height ?? 1024,
|
|
80
|
-
outputFormat: p.outputFormat ?? RUNWARE_DEFAULTS.outputFormat,
|
|
81
|
-
}],
|
|
82
|
-
})));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// ---- 2. Wix Media imports (one per generated image) -----------------------
|
|
86
|
-
const imports = prompts.map((p) => ({
|
|
87
|
-
taskUUID: p.taskUUID,
|
|
88
|
-
mimeType: p.outputFormat === "JPG" ? "image/jpeg" : "image/png",
|
|
89
|
-
displayName: p.displayName ?? `${p.entityId}.${(p.outputFormat ?? "PNG").toLowerCase()}`,
|
|
90
|
-
}));
|
|
91
|
-
|
|
92
|
-
// ---- 3. Per-entity-type write requests ------------------------------------
|
|
93
|
-
const patches = [];
|
|
94
|
-
const publishes = [];
|
|
95
|
-
|
|
96
|
-
for (const p of prompts) {
|
|
97
|
-
if (p.entityType === "product") {
|
|
98
|
-
const detail = productDetails[p.entityId];
|
|
99
|
-
if (!detail) {
|
|
100
|
-
console.error(`plan-entity-image-waves: missing productDetails for entityId=${p.entityId}`);
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
if (detail.revision === undefined || detail.revision === null) {
|
|
104
|
-
console.error(`plan-entity-image-waves: productDetails[${p.entityId}].revision is required (mandatory per Update-Product endpoint)`);
|
|
105
|
-
process.exit(1);
|
|
106
|
-
}
|
|
107
|
-
patches.push({
|
|
108
|
-
taskUUID: p.taskUUID,
|
|
109
|
-
entityType: "product",
|
|
110
|
-
entityId: p.entityId,
|
|
111
|
-
method: "PATCH",
|
|
112
|
-
url: `https://www.wixapis.com/stores/v3/products/${p.entityId}`,
|
|
113
|
-
// Body echoes options + variantsInfo (mandatory — see images/INSTRUCTIONS.md
|
|
114
|
-
// §428-prevention) and embeds the URL via __IMAGE_URL__ placeholder.
|
|
115
|
-
body: {
|
|
116
|
-
product: {
|
|
117
|
-
revision: detail.revision,
|
|
118
|
-
media: {
|
|
119
|
-
itemsInfo: {
|
|
120
|
-
items: [{ url: "__IMAGE_URL__", altText: p.displayName ?? p.entityId }],
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
...(detail.options !== undefined ? { options: detail.options } : {}),
|
|
124
|
-
...(detail.variantsInfo !== undefined ? { variantsInfo: detail.variantsInfo } : {}),
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
} else if (p.entityType === "blogPost") {
|
|
129
|
-
patches.push({
|
|
130
|
-
taskUUID: p.taskUUID,
|
|
131
|
-
entityType: "blogPost",
|
|
132
|
-
entityId: p.entityId,
|
|
133
|
-
method: "PATCH",
|
|
134
|
-
url: `https://www.wixapis.com/blog/v3/draft-posts/${p.entityId}`,
|
|
135
|
-
// Blog uses the file ID (fileUrl), not the wixstatic URL.
|
|
136
|
-
body: {
|
|
137
|
-
draftPost: {
|
|
138
|
-
media: { wixMedia: { image: { id: "__IMAGE_FILE_ID__" } } },
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
publishes.push({
|
|
143
|
-
entityId: p.entityId,
|
|
144
|
-
method: "POST",
|
|
145
|
-
url: `https://www.wixapis.com/blog/v3/draft-posts/${p.entityId}/publish`,
|
|
146
|
-
});
|
|
147
|
-
} else if (p.entityType === "cmsItem") {
|
|
148
|
-
const detail = cmsDetails[p.entityId];
|
|
149
|
-
if (!detail) {
|
|
150
|
-
console.error(`plan-entity-image-waves: missing cmsDetails for entityId=${p.entityId}`);
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
if (!detail.collectionId || !detail.imageField || !detail.data) {
|
|
154
|
-
console.error(`plan-entity-image-waves: cmsDetails[${p.entityId}] requires collectionId, imageField, and data (existing item record)`);
|
|
155
|
-
process.exit(1);
|
|
156
|
-
}
|
|
157
|
-
// Read-merge-PUT: echo every existing data field, set the image field
|
|
158
|
-
// to the placeholder URL. Echoing every existing field is what prevents wiping the rest of the record.
|
|
159
|
-
const mergedData = { ...detail.data, [detail.imageField]: "__IMAGE_URL__" };
|
|
160
|
-
patches.push({
|
|
161
|
-
taskUUID: p.taskUUID,
|
|
162
|
-
entityType: "cmsItem",
|
|
163
|
-
entityId: p.entityId,
|
|
164
|
-
method: "PUT",
|
|
165
|
-
url: `https://www.wixapis.com/wix-data/v2/items/${p.entityId}`,
|
|
166
|
-
body: {
|
|
167
|
-
dataCollectionId: detail.collectionId,
|
|
168
|
-
dataItem: { id: p.entityId, data: mergedData },
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
} else {
|
|
172
|
-
console.error(`plan-entity-image-waves: unknown entityType "${p.entityType}" for entityId=${p.entityId} — must be product | blogPost | cmsItem`);
|
|
173
|
-
process.exit(1);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const plan = {
|
|
178
|
-
meta: {
|
|
179
|
-
promptCount: prompts.length,
|
|
180
|
-
waveCount: waves.length,
|
|
181
|
-
waveSize,
|
|
182
|
-
model,
|
|
183
|
-
},
|
|
184
|
-
waves,
|
|
185
|
-
imports,
|
|
186
|
-
patches,
|
|
187
|
-
publishes,
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
console.log(JSON.stringify(plan, null, 2));
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Scaffold a new Wix Managed Headless project using the CLI's preset blank template.
|
|
3
|
-
#
|
|
4
|
-
# Usage:
|
|
5
|
-
# bash <SKILL_ROOT>/scripts/scaffold.sh <folder-name> "<Brand Name>" [--frontend astro|custom]
|
|
6
|
-
#
|
|
7
|
-
# <folder-name>: lowercase letters, numbers, and hyphens only; must start with a
|
|
8
|
-
# letter or number. The CLI scaffolds into a subdir of this name,
|
|
9
|
-
# which this script then FLATTENS into the current directory (see
|
|
10
|
-
# "In-place flatten" below) — so the project ends up *in CWD*, not
|
|
11
|
-
# in a nested folder. The name is still required (the CLI mandates
|
|
12
|
-
# it) but the local folder is transient.
|
|
13
|
-
# <Brand Name>: human-readable business name; quote if it contains spaces. The
|
|
14
|
-
# CLI derives the Wix project display-name and URL slug from it, so
|
|
15
|
-
# it must include at least one English letter or number.
|
|
16
|
-
# --frontend: the frontend axis. Defaults to "astro" — the only supported (and
|
|
17
|
-
# only scaffolded) frontend. "custom" (any non-astro frontend) is
|
|
18
|
-
# NOT scaffolded yet: Discovery routes custom to the not-available
|
|
19
|
-
# stub (references/custom/INSTRUCTIONS.md) before scaffold ever runs,
|
|
20
|
-
# so this script should only ever be invoked with "astro". If it is
|
|
21
|
-
# invoked with "custom" it exits 4 (recognized, not staged).
|
|
22
|
-
#
|
|
23
|
-
# After scaffold succeeds, the project lives in the CURRENT directory (the subdir
|
|
24
|
-
# was flattened away). Read ./wix.config.json to extract appId (project's appId)
|
|
25
|
-
# and siteId (used as --site for `wix token` and in REST call bodies). The
|
|
26
|
-
# orchestrator does that read; this script runs the npm create + the flatten.
|
|
27
|
-
#
|
|
28
|
-
# Behavior:
|
|
29
|
-
# - Pre-flight validates the folder name syntax (regex ^[a-z0-9][a-z0-9-]*$).
|
|
30
|
-
# - Pre-flight requires both positional args.
|
|
31
|
-
# - Runs `npm create @wix/new@latest headless` with --no-publish + --skip-install
|
|
32
|
-
# so the orchestrator can deferred-install with its own package set.
|
|
33
|
-
# - Passes bare `--site-template` so non-interactive scaffolding stays on the
|
|
34
|
-
# blank starter. Without it, @wix/create-new (>=0.0.72) prompts for a template
|
|
35
|
-
# choice and aborts in a non-TTY agent shell ("not supported in non-interactive
|
|
36
|
-
# terminals").
|
|
37
|
-
# - FLATTENS the scaffolded subdir into CWD (single-folder layout: one `.wix`,
|
|
38
|
-
# CWD == project == site-root). Interim until the CLI supports in-place create.
|
|
39
|
-
#
|
|
40
|
-
# Exit codes:
|
|
41
|
-
# 0 — ok
|
|
42
|
-
# 2 — argument validation failed (bad folder name, missing args, unknown --frontend value)
|
|
43
|
-
# 3 — Wix CLI not logged in (defensive; the Discovery pre-flight is the primary check)
|
|
44
|
-
# 4 — frontend value recognized but not scaffolded yet (custom today)
|
|
45
|
-
# 5 — scaffold succeeded but the subdir could not be flattened into CWD (name collision)
|
|
46
|
-
# <other> — npm create failed; stderr surfaced to caller for orchestrator-side
|
|
47
|
-
# recovery (auth / other scaffold failures live in the orchestrator).
|
|
48
|
-
|
|
49
|
-
set -euo pipefail
|
|
50
|
-
|
|
51
|
-
FRONTEND="astro"
|
|
52
|
-
POSITIONAL=()
|
|
53
|
-
while [[ $# -gt 0 ]]; do
|
|
54
|
-
case "$1" in
|
|
55
|
-
--frontend)
|
|
56
|
-
if [[ $# -lt 2 ]]; then
|
|
57
|
-
echo "scaffold.sh: --frontend requires a value (astro|custom)." >&2
|
|
58
|
-
exit 2
|
|
59
|
-
fi
|
|
60
|
-
FRONTEND="$2"
|
|
61
|
-
shift 2
|
|
62
|
-
;;
|
|
63
|
-
--frontend=*)
|
|
64
|
-
FRONTEND="${1#--frontend=}"
|
|
65
|
-
shift
|
|
66
|
-
;;
|
|
67
|
-
*)
|
|
68
|
-
POSITIONAL+=("$1")
|
|
69
|
-
shift
|
|
70
|
-
;;
|
|
71
|
-
esac
|
|
72
|
-
done
|
|
73
|
-
|
|
74
|
-
if [[ ${#POSITIONAL[@]} -lt 2 || -z "${POSITIONAL[0]:-}" || -z "${POSITIONAL[1]:-}" ]]; then
|
|
75
|
-
echo "scaffold.sh: both positional args required. Got folder-name='${POSITIONAL[0]:-}' brand-name='${POSITIONAL[1]:-}'." >&2
|
|
76
|
-
echo "Usage: bash scaffold.sh <folder-name> \"<Brand Name>\" [--frontend astro|custom] — folder name first, brand quoted." >&2
|
|
77
|
-
exit 2
|
|
78
|
-
fi
|
|
79
|
-
|
|
80
|
-
case "$FRONTEND" in
|
|
81
|
-
astro)
|
|
82
|
-
;;
|
|
83
|
-
custom)
|
|
84
|
-
echo "scaffold.sh: --frontend=custom is not scaffolded yet — astro is the only supported frontend." >&2
|
|
85
|
-
echo "Discovery routes custom (non-astro) frontends to references/custom/INSTRUCTIONS.md (the not-available stub) before scaffold; this script should not be invoked with 'custom'." >&2
|
|
86
|
-
exit 4
|
|
87
|
-
;;
|
|
88
|
-
*)
|
|
89
|
-
echo "scaffold.sh: unknown --frontend value '$FRONTEND'. Allowed: astro, custom." >&2
|
|
90
|
-
exit 2
|
|
91
|
-
;;
|
|
92
|
-
esac
|
|
93
|
-
|
|
94
|
-
if [[ ! "${POSITIONAL[0]}" =~ ^[a-z0-9][a-z0-9-]*$ ]]; then
|
|
95
|
-
echo "scaffold.sh: folder-name='${POSITIONAL[0]}' is not valid." >&2
|
|
96
|
-
echo "Folder name must contain only lowercase letters, numbers, and hyphens, and start with a letter or number." >&2
|
|
97
|
-
echo "Derive it from the brand as a lowercase, npm-safe directory name." >&2
|
|
98
|
-
exit 2
|
|
99
|
-
fi
|
|
100
|
-
|
|
101
|
-
# Defensive auth check — DISCOVERY.md's pre-flight should have caught this
|
|
102
|
-
# already, but scaffold.sh is also a documented standalone entry point
|
|
103
|
-
# (SKILL.md § "When NOT to use this skill"). `npm create @wix/new` requires
|
|
104
|
-
# an active CLI session and otherwise fails mid-run with an opaque error.
|
|
105
|
-
# `wix whoami` exits non-zero on a logged-out session and prints the
|
|
106
|
-
# authenticated email + user id when logged in.
|
|
107
|
-
if ! npx @wix/cli@latest whoami >/dev/null 2>&1; then
|
|
108
|
-
echo "scaffold.sh: not logged in to Wix CLI." >&2
|
|
109
|
-
echo "Run 'npx @wix/cli@latest login' and retry." >&2
|
|
110
|
-
exit 3
|
|
111
|
-
fi
|
|
112
|
-
|
|
113
|
-
FOLDER="${POSITIONAL[0]}"
|
|
114
|
-
|
|
115
|
-
npm create @wix/new@latest headless -- \
|
|
116
|
-
--business-name "${POSITIONAL[1]}" \
|
|
117
|
-
--folder-name "$FOLDER" \
|
|
118
|
-
--site-template \
|
|
119
|
-
--no-publish \
|
|
120
|
-
--skip-install
|
|
121
|
-
|
|
122
|
-
# --- In-place flatten (interim hack) -----------------------------------------
|
|
123
|
-
# The CLI always scaffolds into a named subdir; there is NO in-place option —
|
|
124
|
-
# `headless init` regex-rejects `--folder-name .` ("must contain only lowercase
|
|
125
|
-
# letters, numbers, and hyphens") and offers no --cwd/--here flag. To keep the
|
|
126
|
-
# whole run single-folder (one `.wix`, CWD == project == site-root, no nested
|
|
127
|
-
# `.wix` to reason about), fold the scaffolded subdir up into the current dir.
|
|
128
|
-
#
|
|
129
|
-
# The .wix-merge + mv -n + rmdir logic is identical to flatten.sh (the own-build
|
|
130
|
-
# path's framework-agnostic flatten), so we delegate to it rather than duplicate.
|
|
131
|
-
# flatten.sh lives next to this script; resolve its path relative to our own dir
|
|
132
|
-
# so the call works regardless of CWD. (Both exit 5 on the same name-collision.)
|
|
133
|
-
# When the CLI gains `--folder-name .` (or --cwd), the TODO to drop the flatten
|
|
134
|
-
# lives in flatten.sh.
|
|
135
|
-
if [[ -d "$FOLDER" ]]; then
|
|
136
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
137
|
-
bash "$SCRIPT_DIR/flatten.sh" "$FOLDER"
|
|
138
|
-
fi
|
|
139
|
-
# -----------------------------------------------------------------------------
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Frontend-track project prep: copy the skill's shared utilities into the
|
|
3
|
-
# project's src/utils/ and strip the Astro starter cruft that ships with the
|
|
4
|
-
# blank template. This is local-project (frontend) work, not backend seeding —
|
|
5
|
-
# the orchestrator only runs it in scaffold mode (integrate mode has no
|
|
6
|
-
# skill-written frontend to prep, so it is never invoked there).
|
|
7
|
-
#
|
|
8
|
-
# Usage (both modes work):
|
|
9
|
-
# bash <SKILL_ROOT>/scripts/seed-utilities.sh --template astro
|
|
10
|
-
# bash <(curl -s https://dev.wix.com/skills/wix-headless/scripts/seed-utilities.sh) --template astro
|
|
11
|
-
#
|
|
12
|
-
# --template (optional, default astro): astro
|
|
13
|
-
# Astro is the only frontend the skill scaffolds and preps, so the value is
|
|
14
|
-
# always "astro". Custom (non-astro) frontends route to the not-available stub
|
|
15
|
-
# (references/custom/INSTRUCTIONS.md) and never reach this script.
|
|
16
|
-
#
|
|
17
|
-
# Run from the project directory (CWD = <scaffold>/). The script auto-detects
|
|
18
|
-
# whether shared-utilities is available on disk (tgz install) and falls back
|
|
19
|
-
# to fetching from the well-known URL when streamed via process substitution
|
|
20
|
-
# (BASH_SOURCE is /dev/fd/N, so the on-disk lookup naturally falls through).
|
|
21
|
-
#
|
|
22
|
-
# Behavior:
|
|
23
|
-
# - Copies the three shared utility files into src/utils/ for both templates —
|
|
24
|
-
# never overwrites an existing file (users can drop in their own version).
|
|
25
|
-
# - On --template=astro, removes Astro starter cruft (Welcome.astro + marketing
|
|
26
|
-
# SVGs) that ships with the blank template but is never imported by the build
|
|
27
|
-
# skill.
|
|
28
|
-
#
|
|
29
|
-
# Shared utilities copied:
|
|
30
|
-
# - wix-image.ts — media URL resolver (used by stores, blog, cms)
|
|
31
|
-
# - analytics.ts — event tracking (used by stores, ecom, blog)
|
|
32
|
-
# - ricos.ts — Ricos JSON to HTML renderer for SSR Astro pages
|
|
33
|
-
|
|
34
|
-
set -euo pipefail
|
|
35
|
-
|
|
36
|
-
SKILL_URL="https://dev.wix.com/skills/wix-headless"
|
|
37
|
-
UTILS=(analytics.ts ricos.ts wix-image.ts)
|
|
38
|
-
|
|
39
|
-
TEMPLATE="astro"
|
|
40
|
-
while [[ $# -gt 0 ]]; do
|
|
41
|
-
case "$1" in
|
|
42
|
-
--template)
|
|
43
|
-
TEMPLATE="$2"
|
|
44
|
-
shift 2
|
|
45
|
-
;;
|
|
46
|
-
--template=*)
|
|
47
|
-
TEMPLATE="${1#--template=}"
|
|
48
|
-
shift
|
|
49
|
-
;;
|
|
50
|
-
*)
|
|
51
|
-
echo "seed-utilities.sh: unexpected arg: $1" >&2
|
|
52
|
-
exit 2
|
|
53
|
-
;;
|
|
54
|
-
esac
|
|
55
|
-
done
|
|
56
|
-
|
|
57
|
-
case "$TEMPLATE" in
|
|
58
|
-
astro) ;;
|
|
59
|
-
*)
|
|
60
|
-
echo "seed-utilities.sh: --template must be 'astro' (the only supported frontend); got $TEMPLATE" >&2
|
|
61
|
-
echo "(Custom non-astro frontends route to the stub and never reach this script.)" >&2
|
|
62
|
-
exit 2
|
|
63
|
-
;;
|
|
64
|
-
esac
|
|
65
|
-
|
|
66
|
-
# Mode detection: prefer on-disk skill root if the sibling dir exists, else
|
|
67
|
-
# fetch over HTTP. Covers both tgz install and `bash <(curl ...)` streaming.
|
|
68
|
-
SHARED_UTILS_DIR=""
|
|
69
|
-
script_path="${BASH_SOURCE[0]}"
|
|
70
|
-
if [[ -f "$script_path" ]]; then
|
|
71
|
-
candidate="$(dirname "$script_path")/../shared-utilities"
|
|
72
|
-
if [[ -d "$candidate" ]]; then
|
|
73
|
-
SHARED_UTILS_DIR="$(cd "$candidate" && pwd)"
|
|
74
|
-
fi
|
|
75
|
-
fi
|
|
76
|
-
|
|
77
|
-
mkdir -p src/utils
|
|
78
|
-
|
|
79
|
-
for f in "${UTILS[@]}"; do
|
|
80
|
-
dest="src/utils/$f"
|
|
81
|
-
if [[ -e "$dest" ]]; then continue; fi
|
|
82
|
-
if [[ -n "$SHARED_UTILS_DIR" ]]; then
|
|
83
|
-
cp "$SHARED_UTILS_DIR/$f" "$dest"
|
|
84
|
-
else
|
|
85
|
-
curl -fsSL "$SKILL_URL/shared-utilities/$f" -o "$dest"
|
|
86
|
-
fi
|
|
87
|
-
done
|
|
88
|
-
|
|
89
|
-
# Astro starter cruft cleanup — astro template only.
|
|
90
|
-
if [[ "$TEMPLATE" == "astro" ]]; then
|
|
91
|
-
rm -f src/components/Welcome.astro
|
|
92
|
-
rm -f src/assets/astro.svg src/assets/wix.svg src/assets/background.svg
|
|
93
|
-
fi
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Write the decorative slot→URL map to src/decorative-images.json for a
|
|
3
|
-
// framework-SPA (`own`) frontend. This is the `own`-branch analog of
|
|
4
|
-
// patch-decorative-slots.mjs (which injects <img> into .astro source) — but
|
|
5
|
-
// instead of patching framework source, the generated SPA *imports* this JSON
|
|
6
|
-
// and its hero/about components read it, with a themed-block fallback when a
|
|
7
|
-
// slot is empty/absent. This avoids fragile JSX/Vue/Svelte string-patching and
|
|
8
|
-
// mirrors how the SPA already imports .wix/design-tokens.css.
|
|
9
|
-
//
|
|
10
|
-
// It is called twice in the `own` flow (BUILD-own-build.md):
|
|
11
|
-
// 1. At bootstrap, with EMPTY stdin → writes `{}` (placeholder), so the app
|
|
12
|
-
// builds + renders themed blocks even if Image Phase 1 never runs.
|
|
13
|
-
// 2. At the seed gate (ai-generated only), with Image Phase 1's data.slots
|
|
14
|
-
// piped in → OVERWRITES the file with the real URLs. This MUST happen
|
|
15
|
-
// before `npm run build` (Vite resolves the JSON import at build time).
|
|
16
|
-
//
|
|
17
|
-
// Writes to src/decorative-images.json (inside the Vite root, so it is always
|
|
18
|
-
// importable — unlike .wix/, which may sit outside the bundler root).
|
|
19
|
-
//
|
|
20
|
-
// Usage:
|
|
21
|
-
// echo '{"hero":"https://...","about":"https://..."}' \
|
|
22
|
-
// | node write-decorative-json.mjs <project-dir>
|
|
23
|
-
// : | node write-decorative-json.mjs <project-dir> # placeholder {}
|
|
24
|
-
|
|
25
|
-
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
26
|
-
import { join } from "node:path";
|
|
27
|
-
|
|
28
|
-
const projectDir = process.argv[2] ?? process.cwd();
|
|
29
|
-
|
|
30
|
-
let slots = {};
|
|
31
|
-
if (!process.stdin.isTTY) {
|
|
32
|
-
const raw = readFileSync(0, "utf8").trim();
|
|
33
|
-
if (raw) {
|
|
34
|
-
try {
|
|
35
|
-
slots = JSON.parse(raw);
|
|
36
|
-
} catch (e) {
|
|
37
|
-
console.error(JSON.stringify({ status: "error", reason: `stdin is not valid JSON (${e.message})` }));
|
|
38
|
-
process.exit(2);
|
|
39
|
-
}
|
|
40
|
-
if (!slots || typeof slots !== "object" || Array.isArray(slots)) {
|
|
41
|
-
console.error(JSON.stringify({ status: "error", reason: "expected a JSON object mapping slot keys to URLs" }));
|
|
42
|
-
process.exit(2);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Drop empty/falsy URLs so the component's themed-block fallback kicks in.
|
|
48
|
-
const clean = {};
|
|
49
|
-
for (const [k, v] of Object.entries(slots)) {
|
|
50
|
-
if (typeof v === "string" && v.trim()) clean[k] = v.trim();
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const srcDir = join(projectDir, "src");
|
|
54
|
-
mkdirSync(srcDir, { recursive: true });
|
|
55
|
-
const dest = join(srcDir, "decorative-images.json");
|
|
56
|
-
writeFileSync(dest, JSON.stringify(clean, null, 2) + "\n");
|
|
57
|
-
|
|
58
|
-
console.log(JSON.stringify({
|
|
59
|
-
status: Object.keys(clean).length ? "ok" : "placeholder",
|
|
60
|
-
file: dest,
|
|
61
|
-
slots: Object.keys(clean),
|
|
62
|
-
}, null, 2));
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export type AnalyticsEventName =
|
|
2
|
-
| "AddToCart"
|
|
3
|
-
| "RemoveFromCart"
|
|
4
|
-
| "InitiateCheckout"
|
|
5
|
-
| "Purchase"
|
|
6
|
-
| "ArticleView"
|
|
7
|
-
| "FormSubmit"
|
|
8
|
-
| "AddProductImpression"
|
|
9
|
-
| "ViewContent"
|
|
10
|
-
| "ClickProduct"
|
|
11
|
-
| (string & {});
|
|
12
|
-
|
|
13
|
-
export function trackEvent(
|
|
14
|
-
name: AnalyticsEventName,
|
|
15
|
-
payload?: Record<string, unknown>,
|
|
16
|
-
): void {
|
|
17
|
-
if (typeof window === "undefined") return;
|
|
18
|
-
|
|
19
|
-
const event = { name, ...(payload ?? {}) };
|
|
20
|
-
|
|
21
|
-
const w = window as unknown as {
|
|
22
|
-
dataLayer?: unknown[];
|
|
23
|
-
wixAnalytics?: { track(event: { name: string } & Record<string, unknown>): void };
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (w.wixAnalytics?.track) {
|
|
27
|
-
w.wixAnalytics.track(event);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (w.dataLayer) {
|
|
32
|
-
w.dataLayer.push({ event: name, ...event });
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const meta = import.meta as unknown as { env?: { DEV?: boolean } };
|
|
37
|
-
if (meta.env?.DEV) {
|
|
38
|
-
console.debug("[analytics]", event);
|
|
39
|
-
}
|
|
40
|
-
}
|