@wix/agent-skills 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +111 -0
  3. package/package.json +29 -0
  4. package/skills/wix-app/SKILL.md +344 -0
  5. package/skills/wix-app/references/APP_IDENTIFIERS.md +35 -0
  6. package/skills/wix-app/references/APP_MARKET_REVIEW.md +311 -0
  7. package/skills/wix-app/references/APP_VALIDATION.md +171 -0
  8. package/skills/wix-app/references/BACKEND_API.md +233 -0
  9. package/skills/wix-app/references/BACKEND_EVENT.md +116 -0
  10. package/skills/wix-app/references/CODE_QUALITY.md +33 -0
  11. package/skills/wix-app/references/CUSTOM_ELEMENT_WIDGET.md +587 -0
  12. package/skills/wix-app/references/DASHBOARD_MENU_PLUGIN.md +157 -0
  13. package/skills/wix-app/references/DASHBOARD_MODAL.md +283 -0
  14. package/skills/wix-app/references/DASHBOARD_PAGE.md +403 -0
  15. package/skills/wix-app/references/DASHBOARD_PLUGIN.md +205 -0
  16. package/skills/wix-app/references/DATA_COLLECTION.md +451 -0
  17. package/skills/wix-app/references/DOCUMENTATION.md +42 -0
  18. package/skills/wix-app/references/EDITOR_REACT_COMPONENT.md +65 -0
  19. package/skills/wix-app/references/EMBEDDED_SCRIPT.md +468 -0
  20. package/skills/wix-app/references/EXTENSION_REGISTRATION.md +96 -0
  21. package/skills/wix-app/references/SERVICE_PLUGIN.md +235 -0
  22. package/skills/wix-app/references/SITE_PLUGIN.md +436 -0
  23. package/skills/wix-app/references/STORES_VERSIONING.md +334 -0
  24. package/skills/wix-app/references/backend-event/COMMON-EVENTS.md +84 -0
  25. package/skills/wix-app/references/custom-element-widget/SETTINGS_PANEL.md +345 -0
  26. package/skills/wix-app/references/dashboard-menu-plugin/blog-slots.md +71 -0
  27. package/skills/wix-app/references/dashboard-menu-plugin/bookings-slots.md +58 -0
  28. package/skills/wix-app/references/dashboard-menu-plugin/crm-slots.md +8 -0
  29. package/skills/wix-app/references/dashboard-menu-plugin/ecommerce-slots.md +17 -0
  30. package/skills/wix-app/references/dashboard-menu-plugin/events-slots.md +29 -0
  31. package/skills/wix-app/references/dashboard-menu-plugin/restaurants-slots.md +27 -0
  32. package/skills/wix-app/references/dashboard-menu-plugin/stores-slots.md +35 -0
  33. package/skills/wix-app/references/dashboard-page/API_SPEC.md +138 -0
  34. package/skills/wix-app/references/dashboard-page/DASHBOARD_API.md +573 -0
  35. package/skills/wix-app/references/dashboard-page/DYNAMIC_PARAMETERS.md +269 -0
  36. package/skills/wix-app/references/dashboard-page/ECOM_NAVIGATION.md +164 -0
  37. package/skills/wix-app/references/dashboard-plugin/SLOTS.md +294 -0
  38. package/skills/wix-app/references/data-collection/WIX_DATA.md +270 -0
  39. package/skills/wix-app/references/data-collection/extension-template.ts +107 -0
  40. package/skills/wix-app/references/editor-react-component/ACCESSIBILITY.md +138 -0
  41. package/skills/wix-app/references/editor-react-component/COMPONENT-API.md +454 -0
  42. package/skills/wix-app/references/editor-react-component/COMPONENT-CONFIGURATION.md +165 -0
  43. package/skills/wix-app/references/editor-react-component/CSS-GUIDELINES.md +576 -0
  44. package/skills/wix-app/references/editor-react-component/DIRECTIONALITY.md +170 -0
  45. package/skills/wix-app/references/editor-react-component/EDIT-FLOW.md +6 -0
  46. package/skills/wix-app/references/editor-react-component/PARTS.md +25 -0
  47. package/skills/wix-app/references/editor-react-component/PROPS-VS-CSS.md +203 -0
  48. package/skills/wix-app/references/editor-react-component/REACT-GUIDELINES.md +167 -0
  49. package/skills/wix-app/references/editor-react-component/REACT-PATTERNS.md +137 -0
  50. package/skills/wix-app/references/service-plugin/ADDITIONAL-FEES.md +112 -0
  51. package/skills/wix-app/references/service-plugin/BOOKINGS-STAFF-SORTING.md +118 -0
  52. package/skills/wix-app/references/service-plugin/DISCOUNT-TRIGGERS.md +87 -0
  53. package/skills/wix-app/references/service-plugin/GIFT-CARDS.md +86 -0
  54. package/skills/wix-app/references/service-plugin/PAYMENT-SETTINGS.md +135 -0
  55. package/skills/wix-app/references/service-plugin/SHIPPING-RATES.md +79 -0
  56. package/skills/wix-app/references/service-plugin/VALIDATIONS.md +68 -0
  57. package/skills/wix-app/references/site-plugin/EXAMPLES.md +311 -0
  58. package/skills/wix-app/references/site-plugin/SLOTS.md +263 -0
  59. package/skills/wix-design-system/SKILL.md +129 -0
  60. package/skills/wix-design-system/references/file-structure.md +56 -0
  61. package/skills/wix-design-system/scripts/wds.cjs +531 -0
  62. package/skills/wix-headless/SKILL.md +418 -0
  63. package/skills/wix-headless/references/DISCOVERY.md +332 -0
  64. package/skills/wix-headless/references/ORCHESTRATION.md +269 -0
  65. package/skills/wix-headless/references/SETUP.md +154 -0
  66. package/skills/wix-headless/references/blog/BLOG_CONTENT.md +152 -0
  67. package/skills/wix-headless/references/blog/BLOG_PAGES.md +299 -0
  68. package/skills/wix-headless/references/blog/BLOG_SETUP.md +218 -0
  69. package/skills/wix-headless/references/blog/INSTRUCTIONS.md +32 -0
  70. package/skills/wix-headless/references/cms/CMS_FOUNDATIONS.md +373 -0
  71. package/skills/wix-headless/references/cms/FAQ_KNOWLEDGE_BASE.md +229 -0
  72. package/skills/wix-headless/references/cms/INSTRUCTIONS.md +40 -0
  73. package/skills/wix-headless/references/cms/PORTFOLIO.md +454 -0
  74. package/skills/wix-headless/references/cms/RESOURCE_LIBRARY.md +356 -0
  75. package/skills/wix-headless/references/cms/TEAM_DIRECTORY.md +299 -0
  76. package/skills/wix-headless/references/commands/install-app.md +42 -0
  77. package/skills/wix-headless/references/commands/known-apps.json +5 -0
  78. package/skills/wix-headless/references/commands/mcp-bootstrap.md +28 -0
  79. package/skills/wix-headless/references/designer/INSTRUCTIONS.md +828 -0
  80. package/skills/wix-headless/references/ecom/CART_PAGES.md +120 -0
  81. package/skills/wix-headless/references/ecom/CART_WIRING.md +103 -0
  82. package/skills/wix-headless/references/ecom/COMPONENTS_CSS.md +132 -0
  83. package/skills/wix-headless/references/ecom/INSTRUCTIONS.md +59 -0
  84. package/skills/wix-headless/references/forms/CONTACT_FORM.md +477 -0
  85. package/skills/wix-headless/references/forms/INSTRUCTIONS.md +43 -0
  86. package/skills/wix-headless/references/gift-cards/COMPONENTS.md +119 -0
  87. package/skills/wix-headless/references/gift-cards/INSTRUCTIONS.md +51 -0
  88. package/skills/wix-headless/references/gift-cards/PAGES.md +129 -0
  89. package/skills/wix-headless/references/images/INSTRUCTIONS.md +359 -0
  90. package/skills/wix-headless/references/shared/BUILD_NOISE.md +8 -0
  91. package/skills/wix-headless/references/shared/IMAGE_GENERATION.md +185 -0
  92. package/skills/wix-headless/references/shared/IMPLEMENTER.md +155 -0
  93. package/skills/wix-headless/references/shared/MCP_PREFIX.md +105 -0
  94. package/skills/wix-headless/references/shared/PRODUCTION_SHARP_EDGES.md +97 -0
  95. package/skills/wix-headless/references/shared/RETURN_CONTRACT.md +423 -0
  96. package/skills/wix-headless/references/shared/STYLING.md +117 -0
  97. package/skills/wix-headless/references/stores/BACK_IN_STOCK.md +178 -0
  98. package/skills/wix-headless/references/stores/CATEGORY_PAGES.md +86 -0
  99. package/skills/wix-headless/references/stores/COMPONENTS_CSS.md +129 -0
  100. package/skills/wix-headless/references/stores/HOME_AND_NAV.md +227 -0
  101. package/skills/wix-headless/references/stores/INSTRUCTIONS.md +96 -0
  102. package/skills/wix-headless/references/stores/PRODUCT_CATALOG_DATA.md +249 -0
  103. package/skills/wix-headless/references/stores/PRODUCT_PAGES.md +213 -0
  104. package/skills/wix-headless/references/stores/SHARED_WIRING.md +164 -0
  105. package/skills/wix-headless/references/verticals/_schema.json +160 -0
  106. package/skills/wix-headless/references/verticals/_schema.md +185 -0
  107. package/skills/wix-headless/references/verticals/blog.md +125 -0
  108. package/skills/wix-headless/references/verticals/cms.md +121 -0
  109. package/skills/wix-headless/references/verticals/ecom.md +96 -0
  110. package/skills/wix-headless/references/verticals/forms.md +106 -0
  111. package/skills/wix-headless/references/verticals/gift-cards.md +121 -0
  112. package/skills/wix-headless/references/verticals/stores.md +167 -0
  113. package/skills/wix-headless/scripts/check-manifest.mjs +198 -0
  114. package/skills/wix-headless/scripts/copy-utility-templates.mjs +153 -0
  115. package/skills/wix-headless/scripts/emit-design-tokens.mjs +77 -0
  116. package/skills/wix-headless/scripts/finalize-run-json.mjs +141 -0
  117. package/skills/wix-headless/scripts/init-site-json.mjs +63 -0
  118. package/skills/wix-headless/scripts/patch-decorative-slots.mjs +124 -0
  119. package/skills/wix-headless/scripts/plan-entity-image-waves.mjs +190 -0
  120. package/skills/wix-headless/scripts/preview.sh +45 -0
  121. package/skills/wix-headless/scripts/release.sh +73 -0
  122. package/skills/wix-headless/scripts/scaffold.sh +53 -0
  123. package/skills/wix-headless/scripts/seed-utilities.sh +55 -0
  124. package/skills/wix-headless/shared-utilities/analytics.ts +40 -0
  125. package/skills/wix-headless/shared-utilities/ricos.ts +179 -0
  126. package/skills/wix-headless/shared-utilities/wix-image.ts +72 -0
  127. package/skills/wix-headless/templates/ecom/CartBadge.tsx +84 -0
  128. package/skills/wix-headless/templates/ecom/CartView.tsx +543 -0
  129. package/skills/wix-headless/templates/ecom/cart.astro +13 -0
  130. package/skills/wix-headless/templates/ecom/components-ecom.css +215 -0
  131. package/skills/wix-headless/templates/ecom/discounts.ts +71 -0
  132. package/skills/wix-headless/templates/ecom/thank-you.astro +24 -0
  133. package/skills/wix-headless/templates/gift-cards/GiftCardPurchase.tsx +172 -0
  134. package/skills/wix-headless/templates/gift-cards/_home-teaser-snippet.astro +42 -0
  135. package/skills/wix-headless/templates/gift-cards/_nav-snippet.astro +11 -0
  136. package/skills/wix-headless/templates/gift-cards/components-gift-cards.css +219 -0
  137. package/skills/wix-headless/templates/gift-cards/gift-cards.astro +51 -0
  138. package/skills/wix-headless/templates/gift-cards/gift-cards.ts +75 -0
  139. package/skills/wix-headless/templates/stores/AddToCartButton.tsx +77 -0
  140. package/skills/wix-headless/templates/stores/BackInStockForm.tsx +176 -0
  141. package/skills/wix-headless/templates/stores/CategoryRail.astro +69 -0
  142. package/skills/wix-headless/templates/stores/ProductCard.astro +79 -0
  143. package/skills/wix-headless/templates/stores/ProductPurchase.tsx +397 -0
  144. package/skills/wix-headless/templates/stores/SeoTags.astro +21 -0
  145. package/skills/wix-headless/templates/stores/back-in-stock.ts +67 -0
  146. package/skills/wix-headless/templates/stores/categories.ts +155 -0
  147. package/skills/wix-headless/templates/stores/category/[slug].astro +130 -0
  148. package/skills/wix-headless/templates/stores/components-stores.css +295 -0
  149. package/skills/wix-headless/templates/stores/products/[slug].astro +128 -0
  150. package/skills/wix-headless/templates/stores/products/index.astro +101 -0
  151. package/skills/wix-manage/SKILL.md +280 -0
  152. package/skills/wix-manage/references/app-installation/install-wix-apps.md +155 -0
  153. package/skills/wix-manage/references/app-installation/list-installed-apps.md +124 -0
  154. package/skills/wix-manage/references/blog/how-to-create-blog-posts.md +226 -0
  155. package/skills/wix-manage/references/bookings/booking-service-policy-setup.md +95 -0
  156. package/skills/wix-manage/references/bookings/booking-system-integration-gaps.md +416 -0
  157. package/skills/wix-manage/references/bookings/bookings-staff-setup.md +255 -0
  158. package/skills/wix-manage/references/bookings/create-and-update-booking-services.md +462 -0
  159. package/skills/wix-manage/references/bookings/end-to-end-booking-flow.md +278 -0
  160. package/skills/wix-manage/references/bookings/external-calendar-integration.md +258 -0
  161. package/skills/wix-manage/references/bookings/multi-resource-service-creation.md +231 -0
  162. package/skills/wix-manage/references/calendar/configure-default-business-hours.md +226 -0
  163. package/skills/wix-manage/references/cms/cms-data-items-crud.md +422 -0
  164. package/skills/wix-manage/references/cms/cms-data-operations-extended.md +263 -0
  165. package/skills/wix-manage/references/cms/cms-ecommerce-catalog-integration.md +136 -0
  166. package/skills/wix-manage/references/cms/cms-references-and-relationships.md +160 -0
  167. package/skills/wix-manage/references/cms/cms-schema-management.md +143 -0
  168. package/skills/wix-manage/references/contacts/bulk-delete-contacts.md +73 -0
  169. package/skills/wix-manage/references/contacts/bulk-label-and-unlabel-contacts.md +67 -0
  170. package/skills/wix-manage/references/domains/domain-search-and-purchase.md +434 -0
  171. package/skills/wix-manage/references/ecommerce/api-recommendation-tracking.md +420 -0
  172. package/skills/wix-manage/references/ecommerce/flow-add-free-shipping.md +267 -0
  173. package/skills/wix-manage/references/ecommerce/flow-bundle-and-save.md +290 -0
  174. package/skills/wix-manage/references/ecommerce/flow-fix-coverage-gaps.md +300 -0
  175. package/skills/wix-manage/references/ecommerce/flow-optimize-shipping-rates.md +364 -0
  176. package/skills/wix-manage/references/ecommerce/flow-seasonal-promotion.md +315 -0
  177. package/skills/wix-manage/references/ecommerce/flow-stock-mover.md +308 -0
  178. package/skills/wix-manage/references/ecommerce/flow-upsell-boost.md +271 -0
  179. package/skills/wix-manage/references/ecommerce/goal-clear-inventory.md +118 -0
  180. package/skills/wix-manage/references/ecommerce/goal-drive-cross-sells.md +122 -0
  181. package/skills/wix-manage/references/ecommerce/goal-increase-aov.md +132 -0
  182. package/skills/wix-manage/references/ecommerce/goal-reduce-cart-abandonment.md +148 -0
  183. package/skills/wix-manage/references/ecommerce/goal-seasonal-revenue.md +146 -0
  184. package/skills/wix-manage/references/ecommerce/guardrail-discount-conflicts.md +118 -0
  185. package/skills/wix-manage/references/ecommerce/guardrail-margin-protection.md +88 -0
  186. package/skills/wix-manage/references/ecommerce/guardrail-rate-pricing-sanity.md +108 -0
  187. package/skills/wix-manage/references/ecommerce/guardrail-shipping-health.md +124 -0
  188. package/skills/wix-manage/references/ecommerce/recipe-apply-shipping-recommendations.md +299 -0
  189. package/skills/wix-manage/references/ecommerce/recommend-ecommerce-strategy.md +582 -0
  190. package/skills/wix-manage/references/ecommerce/setup-coupons.md +338 -0
  191. package/skills/wix-manage/references/ecommerce/setup-discount-rules.md +444 -0
  192. package/skills/wix-manage/references/ecommerce/setup-shipping-rates.md +86 -0
  193. package/skills/wix-manage/references/ecommerce/setup-shipping-regions.md +56 -0
  194. package/skills/wix-manage/references/ecommerce/setup-store-pickup-location.md +209 -0
  195. package/skills/wix-manage/references/ecommerce/skill-graph.md +139 -0
  196. package/skills/wix-manage/references/ecommerce/troubleshoot-checkout-delivery-dropoff.md +124 -0
  197. package/skills/wix-manage/references/ecommerce/troubleshoot-discount-not-applying.md +95 -0
  198. package/skills/wix-manage/references/events/list-events.md +203 -0
  199. package/skills/wix-manage/references/forms/create-form.md +260 -0
  200. package/skills/wix-manage/references/get-paid/create-payment-links.md +212 -0
  201. package/skills/wix-manage/references/get-paid/how-to-setup-wix-payments.md +57 -0
  202. package/skills/wix-manage/references/get-paid/payment-links-for-bookings.md +101 -0
  203. package/skills/wix-manage/references/media/upload-media-to-wix.md +216 -0
  204. package/skills/wix-manage/references/pricing-plans/create-and-update-pricing-plans.md +77 -0
  205. package/skills/wix-manage/references/pricing-plans/pricing-plans-bookings-integration.md +166 -0
  206. package/skills/wix-manage/references/restaurants/wix-restaurants-setup.md +336 -0
  207. package/skills/wix-manage/references/rich-content/ricos-converter-service.md +295 -0
  208. package/skills/wix-manage/references/site-properties/change-payment-currency-site-properties.md +59 -0
  209. package/skills/wix-manage/references/sites/create-site-from-template.md +183 -0
  210. package/skills/wix-manage/references/sites/query-sites.md +125 -0
  211. package/skills/wix-manage/references/stores/add-store-pages-to-site.md +57 -0
  212. package/skills/wix-manage/references/stores/bulk-create-products-with-options.md +1041 -0
  213. package/skills/wix-manage/references/stores/create-product-catalog-v1.md +125 -0
  214. package/skills/wix-manage/references/stores/create-product-from-image.md +824 -0
  215. package/skills/wix-manage/references/stores/create-product-with-options-catalog-v3.md +566 -0
  216. package/skills/wix-manage/references/stores/find-products-query-and-search-catalog-v3.md +194 -0
  217. package/skills/wix-manage/references/stores/query-products-catalog-v1.md +80 -0
  218. package/skills/wix-manage/references/stores/setup-online-store-catalog-v3.md +99 -0
  219. package/skills/wix-manage/references/stores/update-product-pre-order.md +213 -0
  220. package/skills/wix-manage/references/stores/update-product-with-options.md +318 -0
@@ -0,0 +1,468 @@
1
+
2
+ # Wix Embedded Script Builder
3
+
4
+ Creates embedded script extensions for Wix CLI applications. Embedded scripts are HTML code fragments that get injected into the DOM of Wix sites, enabling integration with third-party services, analytics tracking, advertising, and custom JavaScript functionality.
5
+
6
+ ## Quick Start Checklist
7
+
8
+ Follow these steps in order when creating an embedded script:
9
+
10
+ 1. [ ] Create script folder: `src/extensions/site/embedded-scripts/<script-name>/`
11
+ 2. [ ] Create `embedded.html` with config element, styles, and script logic
12
+ 3. [ ] Create `extensions.ts` with `extensions.embeddedScript()` and unique UUID
13
+ 4. [ ] Create dashboard config page: `src/extensions/dashboard/pages/<script-name>-settings/`
14
+ 5. [ ] Implement config page with `embeddedScripts` API from `@wix/app-management`
15
+ 6. [ ] Update `src/extensions.ts` to import and use both extensions
16
+ 7. [ ] Add the `SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS` permission in the Wix Dev Center (see [Enable Embedded Script Permission](#enable-embedded-script-permission))
17
+
18
+ ## Script Types
19
+
20
+ Embedded scripts must declare a type for consent management:
21
+
22
+ | Type | Description | Use Cases |
23
+ | ------------- | ------------------------------------------------ | --------------------------------------- |
24
+ | `ESSENTIAL` | Core functionality crucial to site operation | Authentication, security features |
25
+ | `FUNCTIONAL` | Remembers user choices to improve experience | Language preferences, UI customization |
26
+ | `ANALYTICS` | Provides statistics on how visitors use the site | Google Analytics, Hotjar, Mixpanel |
27
+ | `ADVERTISING` | Provides visitor data for marketing purposes | Facebook Pixel, Google Ads, retargeting |
28
+
29
+ **Selection rule:** If a script falls into multiple types, choose the option closest to the bottom of the list (most restrictive). For example, a script with both Analytics and Advertising aspects should be typed as `ADVERTISING`.
30
+
31
+ ## Placement Options
32
+
33
+ | Placement | Description | Best For |
34
+ | ------------ | ---------------------------------------- | --------------------------------- |
35
+ | `HEAD` | Between `<head>` and `</head>` tags | Analytics, early initialization |
36
+ | `BODY_START` | Immediately after opening `<body>` tag | Critical functionality, noscript |
37
+ | `BODY_END` | Immediately before closing `</body>` tag | Non-blocking scripts, performance |
38
+
39
+ **Selection guidelines:**
40
+
41
+ - Analytics/tracking → `HEAD` (initialize early)
42
+ - Advertising pixels → `BODY_END` (non-blocking)
43
+ - Critical functionality → `HEAD` or `BODY_START`
44
+ - Non-critical features → `BODY_END` (better performance)
45
+
46
+ ## Dynamic Parameters and Dashboard Configuration
47
+
48
+ **Every embedded script requires a companion dashboard page** to configure its parameters. Site owners use the dashboard page UI to set values, which are then passed to the embedded script as template variables.
49
+
50
+ ### Architecture Flow
51
+
52
+ ```
53
+ Dashboard Page (React UI)
54
+ │
55
+ │ embeddedScripts.embedScript({ parameters: {...} })
56
+ ▼
57
+ Wix App Management API
58
+ │
59
+ │ Stores parameters, injects as template variables
60
+ ▼
61
+ Embedded Script (HTML)
62
+ │
63
+ │ {{parameterKey}} → actual value
64
+ ▼
65
+ Site DOM
66
+ ```
67
+
68
+ **Related skill:** Use DASHBOARD_PAGE.md to create the configuration UI for your embedded script.
69
+
70
+ ### Parameter Types
71
+
72
+ | Type | Description | Dashboard Component |
73
+ | ---------- | ------------------------ | ---------------------- |
74
+ | `TEXT` | Single-line text | Input |
75
+ | `NUMBER` | Numeric value | Input type="number" |
76
+ | `BOOLEAN` | True/false toggle | ToggleSwitch, Checkbox |
77
+ | `IMAGE` | Image from media manager | ImagePicker |
78
+ | `DATE` | Date only | DatePicker |
79
+ | `DATETIME` | Date with time | DatePicker + TimeInput |
80
+ | `URL` | URL with validation | Input |
81
+ | `SELECT` | Dropdown options | Dropdown |
82
+ | `COLOR` | Color value | ColorPicker |
83
+
84
+ ### Template Variable Syntax
85
+
86
+ Embedded scripts support parameterization using template variable syntax `{{variableName}}`. These parameters are configured through the dashboard and passed as template variables that should be used in your HTML/JavaScript code.
87
+
88
+ **Usage Instructions:**
89
+
90
+ 1. **Template Variable Syntax:**
91
+ - Use `{{parameterKey}}` syntax to insert parameter values into your HTML
92
+ - Template variables work in HTML attributes
93
+ - They will be replaced with actual values when the script is injected
94
+
95
+ 2. **HTML Attributes (REQUIRED):**
96
+ - Store ALL parameter values in data attributes on a configuration element
97
+ - Template variables can ONLY be used here, not directly in JavaScript
98
+ - Example: `<div id="config" data-headline="{{headline}}" data-text="{{text}}"></div>`
99
+
100
+ 3. **JavaScript Access:**
101
+ - JavaScript must read parameter values from the data attributes
102
+ - Use `getAttribute()` or the `dataset` property
103
+ - Examples:
104
+ ```javascript
105
+ const config = document.getElementById("config");
106
+ const headline = config?.getAttribute("data-headline");
107
+ // OR using dataset:
108
+ const { headline, text } = config.dataset;
109
+ ```
110
+
111
+ 4. **Type Safety:**
112
+ - Be aware of parameter types when using them in JavaScript
113
+ - NUMBER types: convert with `Number()` or `parseInt()`
114
+ - BOOLEAN types: compare with `'true'` or `'false'` strings
115
+ - DATE/DATETIME: parse with `new Date()`
116
+
117
+ 5. **Required vs Optional:**
118
+ - Required parameters will always have values
119
+ - Optional parameters may be empty - handle gracefully
120
+ - Provide fallback values for optional parameters
121
+
122
+ 6. **Relevant Parameter Usage:**
123
+ - Only use dynamic parameters that are relevant to your current use case
124
+ - Ignore parameters that don't apply to the functionality you're implementing
125
+ - Each parameter you use should serve a clear purpose in the script's functionality
126
+ - It's perfectly fine to not use all parameters if they're not applicable
127
+
128
+ **Example Patterns:**
129
+
130
+ **Pattern 1 - Configuration in Data Attributes:**
131
+
132
+ ```html
133
+ <div
134
+ id="script-config"
135
+ data-api-key="{{apiKey}}"
136
+ data-enabled="{{enabled}}"
137
+ data-color="{{primaryColor}}"
138
+ ></div>
139
+ <script>
140
+ const config = document.getElementById("script-config");
141
+ const apiKey = config.getAttribute("data-api-key");
142
+ const enabled = config.getAttribute("data-enabled") === "true";
143
+ const color = config.getAttribute("data-color");
144
+
145
+ if (enabled && apiKey) {
146
+ // Initialize with configuration
147
+ }
148
+ </script>
149
+ ```
150
+
151
+ **Pattern 2 - Using dataset Property:**
152
+
153
+ ```html
154
+ <div
155
+ id="script-config"
156
+ data-headline="{{headline}}"
157
+ data-message="{{message}}"
158
+ data-image-url="{{imageUrl}}"
159
+ ></div>
160
+ <script>
161
+ const config = document.getElementById("script-config");
162
+ const { headline, message, imageUrl } = config.dataset;
163
+
164
+ // Use the variables in your script logic
165
+ if (headline) {
166
+ document.querySelector("#headline").textContent = headline;
167
+ }
168
+ </script>
169
+ ```
170
+
171
+ **Pattern 3 - Conditional Logic:**
172
+
173
+ ```html
174
+ <div
175
+ id="config"
176
+ data-mode="{{activationMode}}"
177
+ data-start="{{startDate}}"
178
+ data-end="{{endDate}}"
179
+ ></div>
180
+ <script>
181
+ const config = document.getElementById("config");
182
+ const mode = config.getAttribute("data-mode");
183
+
184
+ if (mode === "timed") {
185
+ const startDate = new Date(config.getAttribute("data-start"));
186
+ const endDate = new Date(config.getAttribute("data-end"));
187
+ const now = new Date();
188
+
189
+ if (now >= startDate && now <= endDate) {
190
+ // Show content
191
+ }
192
+ } else if (mode === "active") {
193
+ // Show content immediately
194
+ }
195
+ </script>
196
+ ```
197
+
198
+ **Validation Requirements:**
199
+
200
+ - Only use dynamic parameters that are relevant to your specific use case
201
+ - Ignore parameters that don't apply to the functionality being implemented
202
+ - Template variables `{{parameterKey}}` must match the exact key names from the parameter definitions
203
+ - Handle both required and optional parameters appropriately
204
+ - Provide sensible default behavior when optional parameters are not set
205
+ - Ensure type-appropriate usage (don't use NUMBER parameters as strings without conversion)
206
+
207
+ ### Common Parameters
208
+
209
+ Every embedded script should have at minimum an **enable/disable toggle** parameter:
210
+
211
+ | Parameter | Type | Purpose |
212
+ | ------------ | --------- | ------------------------------------ |
213
+ | `enabled` | `BOOLEAN` | Allow site owner to activate/disable |
214
+ | `apiKey` | `TEXT` | Third-party service credentials |
215
+ | `trackingId` | `TEXT` | Analytics/pixel identifiers |
216
+ | `headline` | `TEXT` | Customizable display text |
217
+ | `color` | `COLOR` | UI customization |
218
+
219
+ ## Output Structure
220
+
221
+ A complete embedded script implementation requires **two parts**:
222
+
223
+ ### 1. Embedded Script Extension
224
+
225
+ ```
226
+ src/extensions/site/embedded-scripts/
227
+ └── {script-name}/
228
+ ├── embedded.html # HTML/JavaScript code to inject
229
+ └── extensions.ts # Metadata (scriptType, placement)
230
+ ```
231
+
232
+ ### 2. Dashboard Configuration Page (Required)
233
+
234
+ ```
235
+ src/extensions/dashboard/
236
+ ├── withProviders.tsx # WDS provider wrapper (required)
237
+ └── pages/
238
+ └── {script-name}-settings/
239
+ ├── extensions.ts # Extension registration (REQUIRED)
240
+ └── page.tsx # Configuration UI using embeddedScripts API
241
+ ```
242
+
243
+ **Note:** The dashboard page requires its own `extensions.ts` file. Without this file, the dashboard page will not appear in the Wix dashboard.
244
+
245
+ **WARNING:** The dashboard page uses DIFFERENT field names than embedded scripts:
246
+
247
+ - Dashboard pages use `title`, `routePath`, `component`
248
+ - Embedded scripts use `name`, `source`, `placement`, `scriptType`
249
+
250
+ Do NOT apply embedded script field names to dashboard page registrations.
251
+
252
+ **See the DASHBOARD_PAGE.md reference** for dashboard page implementation details and the extension registration pattern.
253
+
254
+ ## Implementation Pattern
255
+
256
+ ```html
257
+ <!-- Configuration element with template variables -->
258
+ <div id="my-config" data-api-key="{{apiKey}}" data-enabled="{{enabled}}"></div>
259
+
260
+ <!-- Container for dynamic content -->
261
+ <div id="my-container"></div>
262
+
263
+ <style>
264
+ /* Scoped styles for the embedded content */
265
+ #my-container {
266
+ /* styles */
267
+ }
268
+ </style>
269
+
270
+ <script type="module">
271
+ // Get configuration from data attributes
272
+ const config = document.getElementById("my-config");
273
+ if (!config) throw new Error("Config element not found");
274
+
275
+ const { apiKey, enabled } = config.dataset;
276
+
277
+ // Exit early if disabled (use throw at module scope, not return)
278
+ if (enabled !== "true") {
279
+ throw new Error("Script disabled");
280
+ }
281
+
282
+ // Implement functionality in a named function (return is allowed here)
283
+ async function initialize() {
284
+ try {
285
+ // Your implementation
286
+ } catch (error) {
287
+ console.error("Script error:", error);
288
+ }
289
+ }
290
+
291
+ // Initialize when DOM is ready
292
+ if (document.readyState === "loading") {
293
+ document.addEventListener("DOMContentLoaded", initialize);
294
+ } else {
295
+ initialize();
296
+ }
297
+ </script>
298
+ ```
299
+
300
+ ## Examples
301
+
302
+ ### Analytics Tracking
303
+
304
+ **Request:** "Add Google Analytics tracking to my site"
305
+
306
+ **Output:**
307
+
308
+ - Script type: `ANALYTICS`
309
+ - Placement: `HEAD`
310
+ - Template variables: `{{trackingId}}`
311
+ - Implements: gtag.js initialization, page view tracking
312
+
313
+ ### Popup/Modal
314
+
315
+ **Request:** "Create a coupon popup that shows when cart value exceeds $50"
316
+
317
+ **Output:**
318
+
319
+ - Script type: `FUNCTIONAL`
320
+ - Placement: `BODY_END`
321
+ - Template variables: `{{couponCode}}`, `{{minimumCartValue}}`, `{{enablePopup}}`
322
+ - Implements: Cart value detection, popup display logic, localStorage for "don't show again"
323
+
324
+ ### Third-Party Chat Widget
325
+
326
+ **Request:** "Integrate Intercom chat widget"
327
+
328
+ **Output:**
329
+
330
+ - Script type: `FUNCTIONAL`
331
+ - Placement: `BODY_END`
332
+ - Template variables: `{{appId}}`, `{{userEmail}}`, `{{userName}}`
333
+ - Implements: Intercom SDK initialization, user identification
334
+
335
+ ## Best Practices
336
+
337
+ - **Always create a dashboard page:** Every embedded script needs a configuration UI
338
+ - **Include enable/disable toggle:** Let site owners control activation without removing the script
339
+ - **Performance:** Minimize impact - scripts should be lightweight and non-blocking
340
+ - **Security:** Avoid inline event handlers, validate data, escape user input
341
+ - **Error handling:** Fail silently when appropriate - don't break the site
342
+ - **Module scope early exits:** Use `throw new Error()` for early exits at module scope, not `return`. Rollup (used by Astro) doesn't allow `return` statements at module scope. Wrap main logic in a named async function where `return` is valid.
343
+ - **Type conversions:** Parameters are always strings - convert in JavaScript as needed
344
+ - **API calls:** Only create fetch() calls to /api/\* endpoints that exist in the API spec
345
+ - **Scoping:** Prefix CSS classes and IDs to avoid conflicts with site styles
346
+ - **Cleanup:** Remove event listeners and intervals when appropriate
347
+
348
+ ## Complete Example: Coupon Popup
349
+
350
+ ### 1. Define Parameters
351
+
352
+ ```
353
+ Parameters for "cart-coupon-popup":
354
+ - couponCode (TEXT, required) - The coupon code to display
355
+ - popupHeadline (TEXT, required) - Headline text
356
+ - popupDescription (TEXT, required) - Description text
357
+ - minimumCartValue (NUMBER) - Minimum cart value to show popup
358
+ - enablePopup (BOOLEAN, required) - Enable/disable toggle
359
+ ```
360
+
361
+ ### 2. Embedded Script (`embedded.html`)
362
+
363
+ ```html
364
+ <div
365
+ id="popup-config"
366
+ data-coupon-code="{{couponCode}}"
367
+ data-popup-headline="{{popupHeadline}}"
368
+ data-minimum-cart-value="{{minimumCartValue}}"
369
+ data-enable-popup="{{enablePopup}}"
370
+ ></div>
371
+ <div id="popup-container"></div>
372
+
373
+ <script type="module">
374
+ // Get configuration from data attributes
375
+ const config = document.getElementById("popup-config");
376
+ if (!config) throw new Error("Config element not found");
377
+
378
+ const { couponCode, popupHeadline, minimumCartValue, enablePopup } =
379
+ config.dataset;
380
+
381
+ // Exit early if disabled (use throw at module scope, not return)
382
+ if (enablePopup !== "true") {
383
+ throw new Error("Popup disabled");
384
+ }
385
+
386
+ // Main logic in a function (return is allowed here)
387
+ async function initializePopup() {
388
+ const minValue = Number(minimumCartValue) || 0;
389
+ // ... popup implementation
390
+ }
391
+
392
+ // Initialize when DOM is ready
393
+ if (document.readyState === "loading") {
394
+ document.addEventListener("DOMContentLoaded", initializePopup);
395
+ } else {
396
+ initializePopup();
397
+ }
398
+ </script>
399
+ ```
400
+
401
+ ### 3. Dashboard Page (See the DASHBOARD_PAGE.md reference)
402
+
403
+ Uses `embeddedScripts` API from `@wix/app-management`:
404
+
405
+ ```typescript
406
+ import { embeddedScripts } from "@wix/app-management";
407
+
408
+ // Load parameters
409
+ const script = await embeddedScripts.getEmbeddedScript();
410
+ const params = script.parameters; // { couponCode: "...", ... }
411
+
412
+ // Save parameters (all values must be strings)
413
+ await embeddedScripts.embedScript({
414
+ parameters: {
415
+ couponCode: "SAVE20",
416
+ minimumCartValue: "50", // Number as string
417
+ enablePopup: "true", // Boolean as string
418
+ },
419
+ });
420
+ ```
421
+
422
+ ## Extension Registration
423
+
424
+ **Extension registration is MANDATORY and has TWO required steps.**
425
+
426
+ ### Step 1: Create Script-Specific Extension File
427
+
428
+ Each embedded script requires an `extensions.ts` file in its folder:
429
+
430
+ ```typescript
431
+ import { extensions } from "@wix/astro/builders";
432
+
433
+ export const embeddedscriptMyScript = extensions.embeddedScript({
434
+ id: "{{GENERATE_UUID}}",
435
+ name: "My Script",
436
+ source: "./extensions/site/embedded-scripts/my-script/embedded.html",
437
+ placement: "BODY_END",
438
+ scriptType: "FUNCTIONAL",
439
+ });
440
+ ```
441
+
442
+ **CRITICAL: UUID Generation**
443
+
444
+ The `id` must be a unique, static UUID v4 string. Generate a fresh UUID for each extension - do NOT use `randomUUID()` or copy UUIDs from examples. Replace `{{GENERATE_UUID}}` with a freshly generated UUID like `"a1b2c3d4-e5f6-7890-abcd-ef1234567890"`.
445
+
446
+ | Property | Type | Description |
447
+ | ------------ | ------ | ----------------------------------------------------- |
448
+ | `id` | string | Unique static UUID v4 (generate fresh) |
449
+ | `name` | string | Display name for the script |
450
+ | `source` | string | Relative path to the HTML file |
451
+ | `placement` | enum | `HEAD`, `BODY_START`, or `BODY_END` |
452
+ | `scriptType` | enum | `ESSENTIAL`, `FUNCTIONAL`, `ANALYTICS`, `ADVERTISING` |
453
+
454
+ ### Step 2: Register in Main Extensions File
455
+
456
+ **CRITICAL:** After creating the script-specific extension file, you MUST read [Extension Registration reference](EXTENSION_REGISTRATION.md) and follow the "App Registration" section to update `src/extensions.ts`.
457
+
458
+ **Without completing Step 2, the embedded script will not be deployed to the site.**
459
+
460
+ ## Enable Embedded Script Permission
461
+
462
+ After implementation, the app developer must manually enable the embedded script permission:
463
+
464
+ 1. Go to [https://manage.wix.com/apps/{app-id}/dev-center-permissions](https://manage.wix.com/apps/{app-id}/dev-center-permissions) (replace `{app-id}` with your actual app ID)
465
+ 2. Add the `SCOPE.DC-APPS.MANAGE-EMBEDDED-SCRIPTS` permission
466
+ 3. Save the changes
467
+
468
+ **Note:** This is a manual step in the Wix Dev Center. Without this permission, embedded scripts will not function on the site.
@@ -0,0 +1,96 @@
1
+
2
+ # Wix App Registration
3
+
4
+ After creating any extension file, you must update the main `src/extensions.ts` file to register the extension with the app.
5
+
6
+ ## Why Registration Matters
7
+
8
+ The Wix CLI discovers extensions through the `src/extensions.ts` file — it's the single entry point that tells the build system which extensions exist. Without registration:
9
+
10
+ - Dashboard pages won't appear in the sidebar
11
+ - Custom element widgets won't show in the Wix Editor
12
+ - Service plugins won't be called during checkout flows
13
+ - Event handlers won't receive webhook deliveries
14
+ - Embedded scripts won't be injected into site pages
15
+
16
+ The most common cause of "my extension isn't working" is a missing `.use()` call in this file.
17
+
18
+ ## Simple Pattern (Recommended for Small Apps)
19
+
20
+ **`src/extensions.ts`** - Import and register extensions directly:
21
+
22
+ ```typescript
23
+ import { app } from "@wix/astro/builders";
24
+ import { dataExtension } from "./extensions/data/extensions.ts";
25
+ import { dashboardpageMyPage } from "./extensions/dashboard/pages/my-page/extensions.ts";
26
+ import { embeddedscriptMyScript } from "./extensions/site/embedded-scripts/my-script/extensions.ts";
27
+
28
+ export default app()
29
+ .use(dataExtension)
30
+ .use(dashboardpageMyPage)
31
+ .use(embeddedscriptMyScript);
32
+ ```
33
+
34
+ **Steps for each new extension:**
35
+
36
+ 1. Import the extension from its `extensions.ts` file
37
+ 2. Add `.use(extensionName)` to the app chain
38
+ 3. Chain multiple extensions together
39
+
40
+ ## Advanced Pattern (For Large Apps)
41
+
42
+ **`src/index.ts`** - Re-export all extensions:
43
+
44
+ ```typescript
45
+ export { dashboardpageMyPage } from "./extensions/dashboard/pages/my-page/extensions";
46
+ export { embeddedscriptMyScript } from "./extensions/site/embedded-scripts/my-script/extensions";
47
+ export { dataExtension } from "./extensions/data/extensions";
48
+ ```
49
+
50
+ **`src/extensions.ts`** - Register all extensions programmatically:
51
+
52
+ ```typescript
53
+ import { app } from "@wix/astro/builders";
54
+ import * as allExtensions from "./index";
55
+
56
+ const extensionList = Object.values(allExtensions);
57
+
58
+ const appBuilder = app();
59
+ extensionList.forEach((extension) => {
60
+ appBuilder.use(extension);
61
+ });
62
+
63
+ export default appBuilder;
64
+ ```
65
+
66
+ ## Extension Types Without Registration
67
+
68
+ The following extension types do **not** require `extensions.ts` files:
69
+
70
+ - **Backend API** - Astro server endpoints are auto-discovered
71
+
72
+ ## Naming Conventions
73
+
74
+ Extension export names follow this pattern: `{extensiontype}{CamelCaseName}`
75
+
76
+ Examples:
77
+
78
+ - `dashboardpageCartPopupManager`
79
+ - `dashboardpluginBlogPostsBanner`
80
+ - `dashboardmenupluginExportPosts`
81
+ - `embeddedscriptCouponPopup`
82
+ - `customelementwidgetCountdownWidget`
83
+ - `sitepluginProductBadge`
84
+ - `ecomshippingratesCustomShipping`
85
+
86
+ The type prefix is the extension type in lowercase with no separators.
87
+
88
+ ## Troubleshooting
89
+
90
+ | Symptom | Cause | Fix |
91
+ |---------|-------|-----|
92
+ | Extension not appearing at all | Missing `.use()` call | Add import and `.use(extensionName)` to `src/extensions.ts` |
93
+ | "Cannot find module" on build | Wrong import path | Verify the path in your import matches the actual file location (relative to `src/`) |
94
+ | Extension registered but not working | Export name mismatch | Ensure the exported name in the extension file matches the import in `extensions.ts` |
95
+ | Multiple extensions, only some work | Incomplete chain | Check that every extension has both an import and a `.use()` call |
96
+ | TypeScript error on `.use()` | Wrong export type | Ensure extension file uses the correct builder method (e.g., `extensions.dashboardPage()` not `extensions.embeddedScript()`) |