@dropins/mcp 0.1.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/LICENSE.md +127 -0
- package/README.md +314 -0
- package/dist/common/project-reader.d.ts +55 -0
- package/dist/common/project-reader.js +173 -0
- package/dist/common/registry-loader.d.ts +101 -0
- package/dist/common/registry-loader.js +386 -0
- package/dist/common/response-handling.d.ts +12 -0
- package/dist/common/response-handling.js +21 -0
- package/dist/common/sanitize.d.ts +8 -0
- package/dist/common/sanitize.js +45 -0
- package/dist/common/synonyms.d.ts +9 -0
- package/dist/common/synonyms.js +127 -0
- package/dist/common/telemetry.d.ts +14 -0
- package/dist/common/telemetry.js +54 -0
- package/dist/common/types.d.ts +308 -0
- package/dist/common/types.js +1 -0
- package/dist/common/version.d.ts +2 -0
- package/dist/common/version.js +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +136 -0
- package/dist/operations/analyze-project.d.ts +13 -0
- package/dist/operations/analyze-project.js +125 -0
- package/dist/operations/check-block-health.d.ts +19 -0
- package/dist/operations/check-block-health.js +1149 -0
- package/dist/operations/check-config.d.ts +13 -0
- package/dist/operations/check-config.js +228 -0
- package/dist/operations/explain-event-flow.d.ts +16 -0
- package/dist/operations/explain-event-flow.js +218 -0
- package/dist/operations/get-upgrade-diff.d.ts +13 -0
- package/dist/operations/get-upgrade-diff.js +144 -0
- package/dist/operations/list-api-functions.d.ts +13 -0
- package/dist/operations/list-api-functions.js +53 -0
- package/dist/operations/list-containers.d.ts +13 -0
- package/dist/operations/list-containers.js +44 -0
- package/dist/operations/list-design-tokens.d.ts +13 -0
- package/dist/operations/list-design-tokens.js +47 -0
- package/dist/operations/list-events.d.ts +16 -0
- package/dist/operations/list-events.js +39 -0
- package/dist/operations/list-graphql-queries.d.ts +19 -0
- package/dist/operations/list-graphql-queries.js +84 -0
- package/dist/operations/list-i18n-keys.d.ts +19 -0
- package/dist/operations/list-i18n-keys.js +105 -0
- package/dist/operations/list-models.d.ts +16 -0
- package/dist/operations/list-models.js +80 -0
- package/dist/operations/list-slots.d.ts +16 -0
- package/dist/operations/list-slots.js +81 -0
- package/dist/operations/scaffold-block.d.ts +31 -0
- package/dist/operations/scaffold-block.js +331 -0
- package/dist/operations/scaffold-extension.d.ts +28 -0
- package/dist/operations/scaffold-extension.js +346 -0
- package/dist/operations/scaffold-slot.d.ts +22 -0
- package/dist/operations/scaffold-slot.js +189 -0
- package/dist/operations/search-commerce-docs.d.ts +16 -0
- package/dist/operations/search-commerce-docs.js +101 -0
- package/dist/operations/search-docs.d.ts +23 -0
- package/dist/operations/search-docs.js +298 -0
- package/dist/operations/suggest-event-handler.d.ts +16 -0
- package/dist/operations/suggest-event-handler.js +175 -0
- package/dist/operations/suggest-slot-implementation.d.ts +19 -0
- package/dist/operations/suggest-slot-implementation.js +183 -0
- package/dist/registry/api-functions.json +3045 -0
- package/dist/registry/block-patterns.json +78 -0
- package/dist/registry/containers.json +2003 -0
- package/dist/registry/design-tokens.json +577 -0
- package/dist/registry/docs/boilerplate.json +55 -0
- package/dist/registry/docs/dropins-all.json +97 -0
- package/dist/registry/docs/dropins-b2b.json +607 -0
- package/dist/registry/docs/dropins-cart.json +163 -0
- package/dist/registry/docs/dropins-checkout.json +193 -0
- package/dist/registry/docs/dropins-order.json +139 -0
- package/dist/registry/docs/dropins-payment-services.json +73 -0
- package/dist/registry/docs/dropins-personalization.json +67 -0
- package/dist/registry/docs/dropins-product-details.json +139 -0
- package/dist/registry/docs/dropins-product-discovery.json +85 -0
- package/dist/registry/docs/dropins-recommendations.json +67 -0
- package/dist/registry/docs/dropins-user-account.json +121 -0
- package/dist/registry/docs/dropins-user-auth.json +103 -0
- package/dist/registry/docs/dropins-wishlist.json +85 -0
- package/dist/registry/docs/get-started.json +85 -0
- package/dist/registry/docs/how-tos.json +19 -0
- package/dist/registry/docs/index.json +139 -0
- package/dist/registry/docs/licensing.json +19 -0
- package/dist/registry/docs/merchants.json +523 -0
- package/dist/registry/docs/resources.json +13 -0
- package/dist/registry/docs/sdk.json +139 -0
- package/dist/registry/docs/setup.json +145 -0
- package/dist/registry/docs/troubleshooting.json +19 -0
- package/dist/registry/events.json +2200 -0
- package/dist/registry/examples/index.json +19 -0
- package/dist/registry/examples/storefront-checkout.json +377 -0
- package/dist/registry/examples/storefront-quote-management.json +49 -0
- package/dist/registry/extensions.json +272 -0
- package/dist/registry/graphql.json +3469 -0
- package/dist/registry/i18n.json +1873 -0
- package/dist/registry/models.json +1001 -0
- package/dist/registry/sdk.json +2357 -0
- package/dist/registry/slots.json +2270 -0
- package/dist/registry/tools-components.json +595 -0
- package/dist/resources/guides.d.ts +7 -0
- package/dist/resources/guides.js +625 -0
- package/dist/resources/handlers.d.ts +31 -0
- package/dist/resources/handlers.js +322 -0
- package/package.json +47 -0
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
export const guides = [
|
|
2
|
+
{
|
|
3
|
+
uri: "storefront://guides/getting-started",
|
|
4
|
+
name: "Getting Started with Adobe Commerce Storefront",
|
|
5
|
+
description: "Overview of the storefront architecture, dropins, AEM blocks, and how to set up a merchant project",
|
|
6
|
+
content: `# Getting Started with Adobe Commerce Storefront
|
|
7
|
+
|
|
8
|
+
## Architecture Overview
|
|
9
|
+
|
|
10
|
+
The Adobe Commerce Storefront is built on a modular architecture with these core concepts:
|
|
11
|
+
|
|
12
|
+
### Dropins
|
|
13
|
+
Dropins are self-contained UI modules that provide functionality for specific commerce pages:
|
|
14
|
+
- **storefront-cart** — Shopping cart display and management
|
|
15
|
+
- **storefront-checkout** — Multi-step or single-step checkout flow
|
|
16
|
+
- **storefront-order** — Order confirmation and history
|
|
17
|
+
- **storefront-pdp** — Product detail pages
|
|
18
|
+
- **storefront-product-discovery** — Search results and filtering
|
|
19
|
+
- **storefront-auth** — Authentication and login
|
|
20
|
+
- **storefront-account** — Customer account management
|
|
21
|
+
- **storefront-requisition-list** — B2B requisition lists
|
|
22
|
+
- **storefront-quote-management** — B2B quote workflows
|
|
23
|
+
|
|
24
|
+
Each dropin exposes:
|
|
25
|
+
- **Containers** — Top-level components you render in AEM blocks
|
|
26
|
+
- **Slots** — Customization points within containers for injecting/replacing UI
|
|
27
|
+
- **API functions** — Programmatic access to commerce data
|
|
28
|
+
- **Events** — Cross-dropin communication via event bus
|
|
29
|
+
|
|
30
|
+
### AEM Blocks
|
|
31
|
+
AEM blocks are the integration layer between the storefront page and dropins.
|
|
32
|
+
Each block typically:
|
|
33
|
+
1. Imports dropin modules (render, containers, API)
|
|
34
|
+
2. Initializes the dropin via the initializer pattern
|
|
35
|
+
3. Renders containers into the block's DOM
|
|
36
|
+
4. Configures slots, events, and extensions
|
|
37
|
+
|
|
38
|
+
### Project Structure
|
|
39
|
+
A merchant storefront project typically contains:
|
|
40
|
+
\`\`\`
|
|
41
|
+
├── blocks/ # AEM blocks (one folder per block)
|
|
42
|
+
│ ├── commerce-cart/ # Cart page block
|
|
43
|
+
│ ├── commerce-checkout/ # Checkout page block
|
|
44
|
+
│ └── ...
|
|
45
|
+
├── scripts/
|
|
46
|
+
│ └── commerce.js # Dropin initializer and config loader
|
|
47
|
+
├── config.json # Storefront configuration
|
|
48
|
+
└── styles/ # Global and dropin-specific CSS
|
|
49
|
+
\`\`\`
|
|
50
|
+
|
|
51
|
+
## Key Concepts
|
|
52
|
+
|
|
53
|
+
### Initializer Pattern
|
|
54
|
+
Every dropin is initialized through a standard pattern:
|
|
55
|
+
\`\`\`javascript
|
|
56
|
+
import { initializer } from '@dropins/storefront-cart/render.js';
|
|
57
|
+
|
|
58
|
+
await initializer.register({
|
|
59
|
+
// configuration
|
|
60
|
+
});
|
|
61
|
+
\`\`\`
|
|
62
|
+
|
|
63
|
+
### Slots Pattern
|
|
64
|
+
Slots allow merchants to customize specific areas of a container:
|
|
65
|
+
\`\`\`javascript
|
|
66
|
+
render(CartSummaryList, {
|
|
67
|
+
routeProduct: (item) => \`/products/\${item.url.urlKey}\`,
|
|
68
|
+
slots: {
|
|
69
|
+
Thumbnail: (ctx) => {
|
|
70
|
+
const { item, appendChild } = ctx;
|
|
71
|
+
// Custom thumbnail rendering
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
})(document.getElementById('cart'));
|
|
75
|
+
\`\`\`
|
|
76
|
+
|
|
77
|
+
### Event Bus
|
|
78
|
+
Dropins communicate through a shared event bus:
|
|
79
|
+
\`\`\`javascript
|
|
80
|
+
import { events } from '@dropins/tools/event-bus.js';
|
|
81
|
+
|
|
82
|
+
events.on('cart/data', (cartData) => {
|
|
83
|
+
// React to cart changes
|
|
84
|
+
});
|
|
85
|
+
\`\`\`
|
|
86
|
+
`,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
uri: "storefront://guides/slots",
|
|
90
|
+
name: "Customizing UI with Slots",
|
|
91
|
+
description: "Complete guide to using slots for dropin UI customization including context methods and patterns",
|
|
92
|
+
content: `# Customizing UI with Slots
|
|
93
|
+
|
|
94
|
+
## What Are Slots?
|
|
95
|
+
|
|
96
|
+
Slots are named extension points inside dropin containers. They allow merchants to:
|
|
97
|
+
- **Append** new content alongside existing UI
|
|
98
|
+
- **Replace** the entire slot content
|
|
99
|
+
- **Modify** HTML within the slot
|
|
100
|
+
- **Add** agreements or custom elements
|
|
101
|
+
|
|
102
|
+
## Slot Context
|
|
103
|
+
|
|
104
|
+
Every slot callback receives a context object with:
|
|
105
|
+
|
|
106
|
+
### Default Methods (available on all slots)
|
|
107
|
+
- \`appendChild(element)\` — Add a child element to the slot
|
|
108
|
+
- \`prependChild(element)\` — Add a child before existing content
|
|
109
|
+
- \`replaceWith(element)\` — Replace the slot's entire content
|
|
110
|
+
- \`removeChild(element)\` — Remove a child element
|
|
111
|
+
- \`appendAgreement(config)\` — Add a checkbox agreement
|
|
112
|
+
- \`replaceHTML(htmlString)\` — Replace inner HTML directly
|
|
113
|
+
|
|
114
|
+
### Custom Context Properties
|
|
115
|
+
Some slots provide additional context specific to their purpose:
|
|
116
|
+
- Cart slots may include \`item\`, \`cart\`, \`prices\`
|
|
117
|
+
- Checkout slots may include \`shippingAddress\`, \`billingAddress\`
|
|
118
|
+
- Order slots may include \`order\`, \`orderData\`
|
|
119
|
+
|
|
120
|
+
## Usage Patterns
|
|
121
|
+
|
|
122
|
+
### Appending Content
|
|
123
|
+
\`\`\`javascript
|
|
124
|
+
slots: {
|
|
125
|
+
ProductDetails: (ctx) => {
|
|
126
|
+
const badge = document.createElement('span');
|
|
127
|
+
badge.textContent = 'New!';
|
|
128
|
+
badge.className = 'custom-badge';
|
|
129
|
+
ctx.appendChild(badge);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
\`\`\`
|
|
133
|
+
|
|
134
|
+
### Replacing Content
|
|
135
|
+
\`\`\`javascript
|
|
136
|
+
slots: {
|
|
137
|
+
Thumbnail: (ctx) => {
|
|
138
|
+
const img = document.createElement('img');
|
|
139
|
+
img.src = ctx.item?.thumbnail?.url;
|
|
140
|
+
img.alt = ctx.item?.thumbnail?.label;
|
|
141
|
+
ctx.replaceWith(img);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
\`\`\`
|
|
145
|
+
|
|
146
|
+
### Adding Agreements (Checkout)
|
|
147
|
+
\`\`\`javascript
|
|
148
|
+
slots: {
|
|
149
|
+
PlaceOrder: (ctx) => {
|
|
150
|
+
ctx.appendAgreement({
|
|
151
|
+
text: 'I accept the terms and conditions',
|
|
152
|
+
required: true,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
\`\`\`
|
|
157
|
+
|
|
158
|
+
### Dynamic Slots
|
|
159
|
+
Some containers have dynamic slots with index-based names:
|
|
160
|
+
- \`ProductListItem_{index}\` — Per-item slots in lists
|
|
161
|
+
- \`Step_{index}\` — Per-step slots in checkout
|
|
162
|
+
|
|
163
|
+
## Finding Available Slots
|
|
164
|
+
|
|
165
|
+
Use the MCP tools to discover slots:
|
|
166
|
+
1. \`list_slots\` — Browse all slots by dropin and container
|
|
167
|
+
2. \`list_containers\` — See which containers have which slot names
|
|
168
|
+
3. Each slot includes its context type, custom methods, and examples
|
|
169
|
+
`,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
uri: "storefront://guides/extensions",
|
|
173
|
+
name: "Checkout Extensions",
|
|
174
|
+
description: "Guide to building checkout extensions for payment methods, validation, and order placement",
|
|
175
|
+
content: `# Checkout Extensions
|
|
176
|
+
|
|
177
|
+
## What Are Extensions?
|
|
178
|
+
|
|
179
|
+
Extensions are a hook-based system exclusive to the checkout dropin. They let merchants:
|
|
180
|
+
- Add custom payment methods
|
|
181
|
+
- Validate checkout steps
|
|
182
|
+
- Intercept order placement
|
|
183
|
+
- Customize address forms
|
|
184
|
+
- Handle payment responses
|
|
185
|
+
|
|
186
|
+
## Extension Interface
|
|
187
|
+
|
|
188
|
+
\`\`\`typescript
|
|
189
|
+
interface Extension {
|
|
190
|
+
name: string; // Unique extension name
|
|
191
|
+
callbacks: {
|
|
192
|
+
'checkout/payment-response'?: (ctx) => Promise<PaymentResponse>;
|
|
193
|
+
'checkout/payment-methods'?: (ctx) => Promise<PaymentMethodConfig[]>;
|
|
194
|
+
'checkout/validate'?: (ctx) => Promise<boolean>;
|
|
195
|
+
'checkout/place-order'?: (ctx) => Promise<PlaceOrderResult>;
|
|
196
|
+
'checkout/address-form-render'?: (ctx) => void;
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
\`\`\`
|
|
200
|
+
|
|
201
|
+
## Available Hooks
|
|
202
|
+
|
|
203
|
+
### checkout/payment-methods
|
|
204
|
+
Register custom payment methods in the checkout UI.
|
|
205
|
+
- **When fired:** During payment method rendering
|
|
206
|
+
- **Context:** \`{ paymentMethods, cart }\`
|
|
207
|
+
- **Returns:** Array of payment method configurations
|
|
208
|
+
|
|
209
|
+
### checkout/validate
|
|
210
|
+
Add custom validation logic before order placement.
|
|
211
|
+
- **When fired:** When the user clicks "Place Order"
|
|
212
|
+
- **Context:** \`{ cart, shippingAddress, billingAddress, paymentMethod }\`
|
|
213
|
+
- **Returns:** \`true\` to continue, \`false\` to block
|
|
214
|
+
|
|
215
|
+
### checkout/place-order
|
|
216
|
+
Customize or intercept the order placement process.
|
|
217
|
+
- **When fired:** After validation passes
|
|
218
|
+
- **Context:** \`{ cart, paymentMethod, shippingAddress, billingAddress }\`
|
|
219
|
+
- **Returns:** Order placement result
|
|
220
|
+
|
|
221
|
+
### checkout/payment-response
|
|
222
|
+
Handle payment gateway responses.
|
|
223
|
+
- **When fired:** After payment processing
|
|
224
|
+
- **Context:** \`{ response, paymentMethod, orderId }\`
|
|
225
|
+
- **Returns:** Processed payment response
|
|
226
|
+
|
|
227
|
+
### checkout/address-form-render
|
|
228
|
+
Customize the address form rendering (add fields, modify layout).
|
|
229
|
+
- **When fired:** When address form mounts
|
|
230
|
+
- **Context:** \`{ form, type ('shipping' | 'billing') }\`
|
|
231
|
+
|
|
232
|
+
## Registering Extensions
|
|
233
|
+
|
|
234
|
+
\`\`\`javascript
|
|
235
|
+
import { initializer } from '@dropins/storefront-checkout/render.js';
|
|
236
|
+
|
|
237
|
+
const myPaymentExtension = {
|
|
238
|
+
name: 'my-custom-payment',
|
|
239
|
+
callbacks: {
|
|
240
|
+
'checkout/payment-methods': async (ctx) => {
|
|
241
|
+
return [{
|
|
242
|
+
code: 'my_payment',
|
|
243
|
+
title: 'My Custom Payment',
|
|
244
|
+
icon: '/icons/payment.svg',
|
|
245
|
+
}];
|
|
246
|
+
},
|
|
247
|
+
'checkout/validate': async (ctx) => {
|
|
248
|
+
// Custom validation logic
|
|
249
|
+
return true;
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
initializer.register({
|
|
255
|
+
extensions: [myPaymentExtension],
|
|
256
|
+
});
|
|
257
|
+
\`\`\`
|
|
258
|
+
|
|
259
|
+
## Existing Extension Examples
|
|
260
|
+
|
|
261
|
+
The storefront-checkout repository includes reference extensions for:
|
|
262
|
+
- Braintree payments (Credit Card, Apple Pay, Google Pay)
|
|
263
|
+
- PayPal
|
|
264
|
+
- Purchase Orders
|
|
265
|
+
- Offline payment methods (Check/Money Order, Bank Transfer)
|
|
266
|
+
- Free method
|
|
267
|
+
`,
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
uri: "storefront://guides/events",
|
|
271
|
+
name: "Cross-Dropin Communication with Events",
|
|
272
|
+
description: "Guide to using the event bus for communication between dropins",
|
|
273
|
+
content: `# Cross-Dropin Communication with Events
|
|
274
|
+
|
|
275
|
+
## Event Bus Overview
|
|
276
|
+
|
|
277
|
+
The event bus (\`@dropins/tools/event-bus.js\`) enables decoupled communication between dropins. Any dropin can emit events and any other dropin (or custom code) can listen.
|
|
278
|
+
|
|
279
|
+
## Core API
|
|
280
|
+
|
|
281
|
+
\`\`\`javascript
|
|
282
|
+
import { events } from '@dropins/tools/event-bus.js';
|
|
283
|
+
|
|
284
|
+
// Listen for an event
|
|
285
|
+
events.on('cart/data', (payload) => {
|
|
286
|
+
console.log('Cart updated:', payload);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
// Emit an event
|
|
290
|
+
events.emit('authenticated', { isAuthenticated: true });
|
|
291
|
+
\`\`\`
|
|
292
|
+
|
|
293
|
+
## Common Event Patterns
|
|
294
|
+
|
|
295
|
+
### Cart Events
|
|
296
|
+
- \`cart/data\` — Cart data changed (items, totals, etc.)
|
|
297
|
+
- \`cart/updated\` — Cart was updated (add/remove/quantity change)
|
|
298
|
+
- \`cart/merged\` — Guest cart merged with customer cart
|
|
299
|
+
|
|
300
|
+
### Checkout Events
|
|
301
|
+
- \`checkout/data\` — Full checkout data updated
|
|
302
|
+
- \`checkout/order\` — Order placed successfully
|
|
303
|
+
- \`checkout/shipping\` — Shipping method selected
|
|
304
|
+
- \`checkout/address\` — Address updated
|
|
305
|
+
|
|
306
|
+
### Authentication Events
|
|
307
|
+
- \`authenticated\` — User authentication state changed
|
|
308
|
+
|
|
309
|
+
### PDP Events
|
|
310
|
+
- \`pdp/data\` — Product data loaded
|
|
311
|
+
- \`addToCart\` — Product added to cart
|
|
312
|
+
|
|
313
|
+
### Order Events
|
|
314
|
+
- \`order/data\` — Order data loaded
|
|
315
|
+
|
|
316
|
+
## Wiring Pattern
|
|
317
|
+
|
|
318
|
+
A typical AEM block wires events to connect dropins:
|
|
319
|
+
|
|
320
|
+
\`\`\`javascript
|
|
321
|
+
// In commerce-cart block
|
|
322
|
+
import { events } from '@dropins/tools/event-bus.js';
|
|
323
|
+
|
|
324
|
+
events.on('addToCart', () => {
|
|
325
|
+
// Refresh mini-cart when product added
|
|
326
|
+
refreshMiniCart();
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
events.on('authenticated', ({ isAuthenticated }) => {
|
|
330
|
+
if (isAuthenticated) {
|
|
331
|
+
// Merge guest cart
|
|
332
|
+
mergeCarts();
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
\`\`\`
|
|
336
|
+
|
|
337
|
+
## Event Payload Types
|
|
338
|
+
|
|
339
|
+
Each event has a defined payload type. Use the \`list_events\` tool to see:
|
|
340
|
+
- Full payload type definitions
|
|
341
|
+
- Which dropins emit each event
|
|
342
|
+
- Which dropins consume each event
|
|
343
|
+
- Usage context and examples
|
|
344
|
+
`,
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
uri: "storefront://guides/design-tokens",
|
|
348
|
+
name: "Theming with Design Tokens",
|
|
349
|
+
description: "Guide to customizing storefront visuals using CSS custom properties and design tokens",
|
|
350
|
+
content: `# Theming with Design Tokens
|
|
351
|
+
|
|
352
|
+
## Overview
|
|
353
|
+
|
|
354
|
+
The storefront uses CSS custom properties (design tokens) scoped under \`.dropin-design\` for consistent theming. Merchants override these tokens in their project CSS to customize the look and feel.
|
|
355
|
+
|
|
356
|
+
## Token Categories
|
|
357
|
+
|
|
358
|
+
### Colors
|
|
359
|
+
Control the color palette:
|
|
360
|
+
- \`--color-brand\` — Primary brand color
|
|
361
|
+
- \`--color-neutral-*\` — Grayscale palette (50 through 900)
|
|
362
|
+
- \`--color-positive-*\` — Success states
|
|
363
|
+
- \`--color-warning-*\` — Warning states
|
|
364
|
+
- \`--color-negative-*\` — Error states
|
|
365
|
+
- \`--color-alert-*\` — Alert/info states
|
|
366
|
+
|
|
367
|
+
### Typography
|
|
368
|
+
Control font properties:
|
|
369
|
+
- \`--type-body-*-size\` — Body text sizes (1 through 3)
|
|
370
|
+
- \`--type-headline-*-size\` — Headline sizes (1 through 3)
|
|
371
|
+
- \`--type-display-*-size\` — Display/hero sizes
|
|
372
|
+
- \`--type-body-font-family\` — Body font family
|
|
373
|
+
- \`--type-headline-font-family\` — Heading font family
|
|
374
|
+
|
|
375
|
+
### Spacing
|
|
376
|
+
Control layout spacing:
|
|
377
|
+
- \`--spacing-xxsmall\` through \`--spacing-xxlarge\`
|
|
378
|
+
- \`--spacing-small\` = 8px (default)
|
|
379
|
+
- \`--spacing-medium\` = 16px (default)
|
|
380
|
+
- \`--spacing-large\` = 24px (default)
|
|
381
|
+
|
|
382
|
+
### Shapes
|
|
383
|
+
Control borders and radius:
|
|
384
|
+
- \`--shape-border-radius-*\` — Border radius (1 through 4)
|
|
385
|
+
- \`--shape-border-width-*\` — Border widths
|
|
386
|
+
- \`--shape-icon-stroke-width\` — Icon stroke width
|
|
387
|
+
|
|
388
|
+
### Grid
|
|
389
|
+
Control layout grid:
|
|
390
|
+
- \`--grid-1-columns\` through \`--grid-5-columns\`
|
|
391
|
+
- \`--grid-*-margin\` — Grid margins
|
|
392
|
+
- \`--grid-*-gutter\` — Grid gutters
|
|
393
|
+
|
|
394
|
+
## Applying Overrides
|
|
395
|
+
|
|
396
|
+
Create a CSS file in your project:
|
|
397
|
+
|
|
398
|
+
\`\`\`css
|
|
399
|
+
/* styles/dropin-overrides.css */
|
|
400
|
+
.dropin-design {
|
|
401
|
+
--color-brand: #e03e2d;
|
|
402
|
+
--type-body-font-family: 'Inter', sans-serif;
|
|
403
|
+
--type-headline-font-family: 'Playfair Display', serif;
|
|
404
|
+
--spacing-medium: 20px;
|
|
405
|
+
--shape-border-radius-1: 8px;
|
|
406
|
+
}
|
|
407
|
+
\`\`\`
|
|
408
|
+
|
|
409
|
+
## Best Practices
|
|
410
|
+
|
|
411
|
+
1. **Override at the root level** — Set tokens on \`.dropin-design\` not on individual components
|
|
412
|
+
2. **Use the token hierarchy** — Tokens cascade; override high-level tokens first
|
|
413
|
+
3. **Test across dropins** — Token changes affect ALL dropins consistently
|
|
414
|
+
4. **Respect semantic meaning** — \`--color-positive\` should always indicate success
|
|
415
|
+
5. **Use \`list_design_tokens\` tool** — See all available tokens with default values
|
|
416
|
+
`,
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
uri: "storefront://guides/block-patterns",
|
|
420
|
+
name: "AEM Block Patterns",
|
|
421
|
+
description: "Guide to creating AEM blocks that render dropin containers with various patterns",
|
|
422
|
+
content: `# AEM Block Patterns
|
|
423
|
+
|
|
424
|
+
## Block Lifecycle
|
|
425
|
+
|
|
426
|
+
Every AEM block follows this lifecycle:
|
|
427
|
+
1. **Decorate** — The \`decorate(block)\` function is called with the block DOM element
|
|
428
|
+
2. **Initialize** — Import and register the dropin initializer
|
|
429
|
+
3. **Render** — Render dropin containers into the block
|
|
430
|
+
4. **Configure** — Set up slots, events, and extensions
|
|
431
|
+
|
|
432
|
+
## Basic Block Structure
|
|
433
|
+
|
|
434
|
+
\`\`\`javascript
|
|
435
|
+
import { initializer } from '@dropins/storefront-cart/render.js';
|
|
436
|
+
import * as Cart from '@dropins/storefront-cart/containers/CartSummaryList.js';
|
|
437
|
+
|
|
438
|
+
export default async function decorate(block) {
|
|
439
|
+
// Initialize the dropin
|
|
440
|
+
await initializer.register({
|
|
441
|
+
// dropin config
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
// Render a container
|
|
445
|
+
return Cart.render(Cart.CartSummaryList, {
|
|
446
|
+
routeProduct: (item) => \\\`/products/\\\${item.url.urlKey}\\\`,
|
|
447
|
+
slots: {
|
|
448
|
+
// slot customizations
|
|
449
|
+
},
|
|
450
|
+
})(block);
|
|
451
|
+
}
|
|
452
|
+
\`\`\`
|
|
453
|
+
|
|
454
|
+
## Common Patterns
|
|
455
|
+
|
|
456
|
+
### Single Container
|
|
457
|
+
The simplest pattern — one block, one container.
|
|
458
|
+
|
|
459
|
+
### Multi-Container
|
|
460
|
+
Render multiple containers in a single block with layout:
|
|
461
|
+
\`\`\`javascript
|
|
462
|
+
const left = document.createElement('div');
|
|
463
|
+
const right = document.createElement('div');
|
|
464
|
+
block.append(left, right);
|
|
465
|
+
|
|
466
|
+
Cart.render(CartSummaryList, { ... })(left);
|
|
467
|
+
Cart.render(OrderSummary, { ... })(right);
|
|
468
|
+
\`\`\`
|
|
469
|
+
|
|
470
|
+
### With Events
|
|
471
|
+
Wire cross-dropin communication:
|
|
472
|
+
\`\`\`javascript
|
|
473
|
+
import { events } from '@dropins/tools/event-bus.js';
|
|
474
|
+
|
|
475
|
+
events.on('cart/updated', () => {
|
|
476
|
+
// Refresh related UI
|
|
477
|
+
});
|
|
478
|
+
\`\`\`
|
|
479
|
+
|
|
480
|
+
### With Extensions (Checkout)
|
|
481
|
+
Register checkout extensions:
|
|
482
|
+
\`\`\`javascript
|
|
483
|
+
initializer.register({
|
|
484
|
+
extensions: [myPaymentExtension, myValidationExtension],
|
|
485
|
+
});
|
|
486
|
+
\`\`\`
|
|
487
|
+
|
|
488
|
+
### With Config
|
|
489
|
+
Read from storefront configuration:
|
|
490
|
+
\`\`\`javascript
|
|
491
|
+
const config = readBlockConfig(block);
|
|
492
|
+
// Use config values for conditional rendering
|
|
493
|
+
\`\`\`
|
|
494
|
+
|
|
495
|
+
## Block Discovery
|
|
496
|
+
|
|
497
|
+
Use the \`scaffold_block\` tool (Phase 4) to generate blocks from templates.
|
|
498
|
+
Use the \`list_containers\` tool to see which containers to render in your block.
|
|
499
|
+
`,
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
uri: "storefront://guides/graphql-overrides",
|
|
503
|
+
name: "Extending GraphQL Queries",
|
|
504
|
+
description: "Guide to overriding and extending default GraphQL queries in dropins using overrideGQLOperations from build-tools",
|
|
505
|
+
content: `# Extending GraphQL Queries
|
|
506
|
+
|
|
507
|
+
## Overview
|
|
508
|
+
|
|
509
|
+
Each dropin uses pre-defined GraphQL queries, mutations, and fragments. Merchants can extend these at build time using \`overrideGQLOperations\` from \`@dropins/build-tools\`, or explore them with the \`list_graphql_queries\` tool.
|
|
510
|
+
|
|
511
|
+
Use cases:
|
|
512
|
+
- Add custom attributes to product, cart, or checkout data
|
|
513
|
+
- Include additional fields in order responses
|
|
514
|
+
- Remove unused fragments to reduce payload size
|
|
515
|
+
- Support B2B-specific or custom module fields
|
|
516
|
+
|
|
517
|
+
## Discovering Available Queries
|
|
518
|
+
|
|
519
|
+
Use the \`list_graphql_queries\` tool to see what each dropin fetches:
|
|
520
|
+
- \`list_graphql_queries({ dropin: "storefront-checkout" })\` — full resolved source with fragments
|
|
521
|
+
- \`list_graphql_queries({ type: "mutation" })\` — all mutations across dropins
|
|
522
|
+
- \`list_graphql_queries({ name: "getCart" })\` — search by operation name
|
|
523
|
+
|
|
524
|
+
Each operation includes the complete GraphQL source with all fragments resolved, so you can see exactly which fields are queried.
|
|
525
|
+
|
|
526
|
+
## Override Method: overrideGQLOperations (Recommended)
|
|
527
|
+
|
|
528
|
+
The official way to extend GraphQL is via \`overrideGQLOperations\` in your project's \`build.mjs\`:
|
|
529
|
+
|
|
530
|
+
\`\`\`javascript
|
|
531
|
+
// build.mjs (project root)
|
|
532
|
+
import { overrideGQLOperations } from '@dropins/build-tools/gql-extend.js';
|
|
533
|
+
|
|
534
|
+
overrideGQLOperations([
|
|
535
|
+
// Example 1: Add a custom field to the cart fragment
|
|
536
|
+
{
|
|
537
|
+
npm: '@dropins/storefront-cart',
|
|
538
|
+
operations: [
|
|
539
|
+
\\\`fragment CART_FRAGMENT on Cart {
|
|
540
|
+
gift_message {
|
|
541
|
+
from
|
|
542
|
+
to
|
|
543
|
+
message
|
|
544
|
+
}
|
|
545
|
+
my_custom_field
|
|
546
|
+
}\\\`,
|
|
547
|
+
],
|
|
548
|
+
},
|
|
549
|
+
|
|
550
|
+
// Example 2: Remove an unused fragment to reduce payload
|
|
551
|
+
{
|
|
552
|
+
npm: '@dropins/storefront-cart',
|
|
553
|
+
skipFragments: ['DOWNLOADABLE_CART_ITEMS_FRAGMENT'],
|
|
554
|
+
operations: [],
|
|
555
|
+
},
|
|
556
|
+
|
|
557
|
+
// Example 3: Extend checkout data
|
|
558
|
+
{
|
|
559
|
+
npm: '@dropins/storefront-checkout',
|
|
560
|
+
operations: [
|
|
561
|
+
\\\`fragment CHECKOUT_DATA_FRAGMENT on Cart {
|
|
562
|
+
delivery_estimate
|
|
563
|
+
loyalty_points_earned
|
|
564
|
+
}\\\`,
|
|
565
|
+
],
|
|
566
|
+
},
|
|
567
|
+
]);
|
|
568
|
+
\`\`\`
|
|
569
|
+
|
|
570
|
+
## How It Works
|
|
571
|
+
|
|
572
|
+
1. Each dropin publishes a \`fragments.js\` file containing all its GraphQL fragments
|
|
573
|
+
2. \`overrideGQLOperations\` modifies these fragment files in \`node_modules\` at build time
|
|
574
|
+
3. **operations**: Fragment strings that get merged into existing fragments (adds fields, does not replace)
|
|
575
|
+
4. **skipFragments**: Fragment names to completely remove from the dropin's queries
|
|
576
|
+
|
|
577
|
+
The merge is additive — your fragment fields are added to the existing fragment. You do NOT need to provide the full fragment, only the new fields.
|
|
578
|
+
|
|
579
|
+
## Important Notes
|
|
580
|
+
|
|
581
|
+
1. **Additive merge** — \`operations\` adds fields to existing fragments, it does not replace them
|
|
582
|
+
2. **Match fragment names** — Use the exact fragment name from the dropin (check with \`list_graphql_queries\`)
|
|
583
|
+
3. **Match type condition** — Your fragment must use the same GraphQL type (e.g., \`on Cart\`, \`on CartAddress\`)
|
|
584
|
+
4. **Build-time only** — Overrides are applied during build, not at runtime
|
|
585
|
+
5. **Backup system** — The first build creates \`fragments.original.js\`; subsequent builds restore from it before applying overrides
|
|
586
|
+
|
|
587
|
+
## Common Patterns
|
|
588
|
+
|
|
589
|
+
### Adding custom product attributes
|
|
590
|
+
\`\`\`javascript
|
|
591
|
+
{
|
|
592
|
+
npm: '@dropins/storefront-pdp',
|
|
593
|
+
operations: [
|
|
594
|
+
\\\`fragment PRODUCT_FRAGMENT on ProductInterface {
|
|
595
|
+
delivery_estimate
|
|
596
|
+
custom_label
|
|
597
|
+
}\\\`,
|
|
598
|
+
],
|
|
599
|
+
}
|
|
600
|
+
\`\`\`
|
|
601
|
+
|
|
602
|
+
### Adding B2B fields to checkout
|
|
603
|
+
\`\`\`javascript
|
|
604
|
+
{
|
|
605
|
+
npm: '@dropins/storefront-checkout',
|
|
606
|
+
operations: [
|
|
607
|
+
\\\`fragment CHECKOUT_DATA_FRAGMENT on Cart {
|
|
608
|
+
purchase_order_number
|
|
609
|
+
company_credit { balance { value currency } }
|
|
610
|
+
}\\\`,
|
|
611
|
+
],
|
|
612
|
+
}
|
|
613
|
+
\`\`\`
|
|
614
|
+
|
|
615
|
+
### Reducing payload size
|
|
616
|
+
\`\`\`javascript
|
|
617
|
+
{
|
|
618
|
+
npm: '@dropins/storefront-order',
|
|
619
|
+
skipFragments: ['DOWNLOADABLE_ORDER_ITEMS_FRAGMENT'],
|
|
620
|
+
operations: [],
|
|
621
|
+
}
|
|
622
|
+
\`\`\`
|
|
623
|
+
`,
|
|
624
|
+
},
|
|
625
|
+
];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
interface RegistryResourceDef {
|
|
2
|
+
uri: string;
|
|
3
|
+
name: string;
|
|
4
|
+
mimeType: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getResourceHandlers: () => {
|
|
8
|
+
listResources: () => Promise<{
|
|
9
|
+
resources: RegistryResourceDef[];
|
|
10
|
+
}>;
|
|
11
|
+
listResourceTemplates: () => Promise<{
|
|
12
|
+
resourceTemplates: {
|
|
13
|
+
uriTemplate: string;
|
|
14
|
+
name: string;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
description: string;
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
19
|
+
readResource: (request: {
|
|
20
|
+
params: {
|
|
21
|
+
uri: string;
|
|
22
|
+
};
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
contents: {
|
|
25
|
+
uri: string;
|
|
26
|
+
mimeType: string;
|
|
27
|
+
text: string;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
export {};
|