@salesforce/b2c-dx-mcp 2.0.0 → 2.1.1
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 +15 -62
- package/dist/commands/mcp.d.ts +1 -0
- package/dist/commands/mcp.js +41 -9
- package/dist/registry.d.ts +3 -4
- package/dist/registry.js +7 -14
- package/dist/server.d.ts +1 -1
- package/dist/server.js +3 -1
- package/dist/services.d.ts +21 -1
- package/dist/services.js +39 -6
- package/dist/tools/adapter.d.ts +18 -2
- package/dist/tools/adapter.js +49 -10
- package/dist/tools/cartridges/index.js +16 -22
- package/dist/tools/diagnostics/config-inspect.js +4 -8
- package/dist/tools/diagnostics/debug-capture-at-breakpoint.js +3 -9
- package/dist/tools/diagnostics/debug-list-sessions.js +1 -0
- package/dist/tools/diagnostics/debug-start-session.js +16 -9
- package/dist/tools/diagnostics/debug-wait-for-stop.js +1 -3
- package/dist/tools/diagnostics/log-watch-registry.d.ts +3 -0
- package/dist/tools/diagnostics/log-watch-registry.js +1 -0
- package/dist/tools/diagnostics/logs-get-recent.js +2 -5
- package/dist/tools/diagnostics/logs-list-files.js +1 -1
- package/dist/tools/diagnostics/logs-watch-list.js +1 -0
- package/dist/tools/diagnostics/logs-watch-start.js +10 -10
- package/dist/tools/diagnostics/mrt-log-watch-registry.d.ts +3 -0
- package/dist/tools/diagnostics/mrt-log-watch-registry.js +0 -0
- package/dist/tools/diagnostics/mrt-logs-watch-list.js +1 -0
- package/dist/tools/diagnostics/mrt-logs-watch-poll.js +2 -5
- package/dist/tools/diagnostics/mrt-logs-watch-start.js +9 -8
- package/dist/tools/diagnostics/session-registry.d.ts +3 -0
- package/dist/tools/diagnostics/session-registry.js +2 -1
- package/dist/tools/docs/docs-list.js +4 -6
- package/dist/tools/docs/docs-read.js +2 -9
- package/dist/tools/docs/docs-schema-list.js +1 -1
- package/dist/tools/docs/docs-schema-read.js +2 -3
- package/dist/tools/docs/docs-schema-search.js +2 -2
- package/dist/tools/docs/docs-search.js +3 -9
- package/dist/tools/docs/storefront.js +3 -3
- package/dist/tools/docs/topics.js +3 -1
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +0 -1
- package/dist/tools/mrt/index.js +6 -2
- package/dist/tools/project-context.d.ts +38 -11
- package/dist/tools/project-context.js +32 -15
- package/dist/tools/pwav3/pwa-kit-development-guidelines.js +3 -43
- package/dist/tools/scapi/metrics-get.js +5 -23
- package/dist/tools/scapi/scapi-custom-api-generate-scaffold.d.ts +4 -0
- package/dist/tools/scapi/scapi-custom-api-generate-scaffold.js +29 -14
- package/dist/tools/scapi/scapi-custom-apis-get-status.js +3 -14
- package/dist/tools/scapi/scapi-schemas-list.js +11 -11
- package/dist/utils/constants.d.ts +2 -13
- package/dist/utils/constants.js +1 -20
- package/oclif.manifest.json +2 -2
- package/package.json +5 -5
- package/content/sfnext/auth.md +0 -62
- package/content/sfnext/components.md +0 -123
- package/content/sfnext/config.md +0 -180
- package/content/sfnext/data-fetching.md +0 -323
- package/content/sfnext/extensions.md +0 -80
- package/content/sfnext/i18n.md +0 -121
- package/content/sfnext/page-designer.md +0 -78
- package/content/sfnext/performance.md +0 -80
- package/content/sfnext/pitfalls.md +0 -141
- package/content/sfnext/quick-reference.md +0 -226
- package/content/sfnext/state-management.md +0 -75
- package/content/sfnext/styling.md +0 -51
- package/content/sfnext/testing.md +0 -232
- package/dist/tools/storefrontnext/figma/figma-to-component/figma-url-parser.d.ts +0 -24
- package/dist/tools/storefrontnext/figma/figma-to-component/figma-url-parser.js +0 -53
- package/dist/tools/storefrontnext/figma/figma-to-component/index.d.ts +0 -45
- package/dist/tools/storefrontnext/figma/figma-to-component/index.js +0 -332
- package/dist/tools/storefrontnext/figma/generate-component/decision.d.ts +0 -40
- package/dist/tools/storefrontnext/figma/generate-component/decision.js +0 -312
- package/dist/tools/storefrontnext/figma/generate-component/formatter.d.ts +0 -9
- package/dist/tools/storefrontnext/figma/generate-component/formatter.js +0 -92
- package/dist/tools/storefrontnext/figma/generate-component/index.d.ts +0 -117
- package/dist/tools/storefrontnext/figma/generate-component/index.js +0 -102
- package/dist/tools/storefrontnext/figma/map-tokens/css-parser.d.ts +0 -71
- package/dist/tools/storefrontnext/figma/map-tokens/css-parser.js +0 -260
- package/dist/tools/storefrontnext/figma/map-tokens/index.d.ts +0 -64
- package/dist/tools/storefrontnext/figma/map-tokens/index.js +0 -242
- package/dist/tools/storefrontnext/figma/map-tokens/token-matcher.d.ts +0 -65
- package/dist/tools/storefrontnext/figma/map-tokens/token-matcher.js +0 -268
- package/dist/tools/storefrontnext/index.d.ts +0 -30
- package/dist/tools/storefrontnext/index.js +0 -28
- package/dist/tools/storefrontnext/page-designer-decorator/analyzer.d.ts +0 -169
- package/dist/tools/storefrontnext/page-designer-decorator/analyzer.js +0 -567
- package/dist/tools/storefrontnext/page-designer-decorator/index.d.ts +0 -259
- package/dist/tools/storefrontnext/page-designer-decorator/index.js +0 -622
- package/dist/tools/storefrontnext/page-designer-decorator/rules/1-mode-selection.d.ts +0 -8
- package/dist/tools/storefrontnext/page-designer-decorator/rules/1-mode-selection.js +0 -65
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2a-auto-mode.d.ts +0 -13
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2a-auto-mode.js +0 -87
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-0-interactive-overview.d.ts +0 -4
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-0-interactive-overview.js +0 -55
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-1-interactive-analyze.d.ts +0 -22
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-1-interactive-analyze.js +0 -109
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-2-interactive-select-props.d.ts +0 -21
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-2-interactive-select-props.js +0 -60
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-3-interactive-configure-attrs.d.ts +0 -27
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-3-interactive-configure-attrs.js +0 -68
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-4-interactive-configure-regions.d.ts +0 -4
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-4-interactive-configure-regions.js +0 -65
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-5-interactive-confirm-generation.d.ts +0 -11
- package/dist/tools/storefrontnext/page-designer-decorator/rules/2b-5-interactive-confirm-generation.js +0 -92
- package/dist/tools/storefrontnext/page-designer-decorator/rules.d.ts +0 -51
- package/dist/tools/storefrontnext/page-designer-decorator/rules.js +0 -70
- package/dist/tools/storefrontnext/page-designer-decorator/templates/decorator-generator.d.ts +0 -116
- package/dist/tools/storefrontnext/page-designer-decorator/templates/decorator-generator.js +0 -350
- package/dist/tools/storefrontnext/sfnext-development-guidelines.d.ts +0 -9
- package/dist/tools/storefrontnext/sfnext-development-guidelines.js +0 -141
- package/dist/tools/storefrontnext/site-theming/color-contrast.d.ts +0 -92
- package/dist/tools/storefrontnext/site-theming/color-contrast.js +0 -186
- package/dist/tools/storefrontnext/site-theming/color-mapping.d.ts +0 -16
- package/dist/tools/storefrontnext/site-theming/color-mapping.js +0 -131
- package/dist/tools/storefrontnext/site-theming/guidance-merger.d.ts +0 -11
- package/dist/tools/storefrontnext/site-theming/guidance-merger.js +0 -78
- package/dist/tools/storefrontnext/site-theming/index.d.ts +0 -14
- package/dist/tools/storefrontnext/site-theming/index.js +0 -128
- package/dist/tools/storefrontnext/site-theming/response-builder.d.ts +0 -16
- package/dist/tools/storefrontnext/site-theming/response-builder.js +0 -316
- package/dist/tools/storefrontnext/site-theming/theming-store.d.ts +0 -64
- package/dist/tools/storefrontnext/site-theming/theming-store.js +0 -417
- package/dist/tools/storefrontnext/site-theming/types.d.ts +0 -36
- package/dist/tools/storefrontnext/site-theming/types.js +0 -7
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
# Testing Strategy
|
|
2
|
-
|
|
3
|
-
## Unit Tests (Vitest)
|
|
4
|
-
|
|
5
|
-
This project uses **Vitest** for unit tests, running under Vite with jsdom as the default test environment.
|
|
6
|
-
|
|
7
|
-
### Test File Organization
|
|
8
|
-
|
|
9
|
-
Tests live alongside source files with `.test.ts` or `.test.tsx` extension:
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
// src/components/product-card/product-card.test.tsx
|
|
13
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
14
|
-
import { render, screen } from '@testing-library/react';
|
|
15
|
-
import { ProductCard } from './product-card';
|
|
16
|
-
import { mockProduct } from '@/test-utils/mocks';
|
|
17
|
-
|
|
18
|
-
describe('ProductCard', () => {
|
|
19
|
-
it('renders product name', () => {
|
|
20
|
-
render(<ProductCard product={mockProduct} />);
|
|
21
|
-
expect(screen.getByText(mockProduct.productName)).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
### Test Utilities
|
|
27
|
-
|
|
28
|
-
Test utilities are available in `src/test-utils/`:
|
|
29
|
-
- `config.ts` - Mock configuration objects and ConfigProvider wrappers
|
|
30
|
-
- `context-provider-utils.ts` - Context provider helpers for testing
|
|
31
|
-
- `context-provider.tsx` - Test context providers
|
|
32
|
-
|
|
33
|
-
### Running Tests
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Run all tests with coverage
|
|
37
|
-
pnpm test
|
|
38
|
-
|
|
39
|
-
# Open Vitest UI (interactive test runner)
|
|
40
|
-
pnpm test:ui
|
|
41
|
-
|
|
42
|
-
# Watch mode (re-run on file changes)
|
|
43
|
-
pnpm test:watch
|
|
44
|
-
|
|
45
|
-
# Generate coverage report
|
|
46
|
-
pnpm test
|
|
47
|
-
# Coverage report outputs to console and coverage/ directory
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Coverage Requirements
|
|
51
|
-
|
|
52
|
-
Coverage thresholds are enforced in `vitest.thresholds.ts`:
|
|
53
|
-
- Lines: 73%
|
|
54
|
-
- Statements: 73%
|
|
55
|
-
- Functions: 86%
|
|
56
|
-
- Branches: 87%
|
|
57
|
-
|
|
58
|
-
These thresholds represent minimum values that must not be undershot. They should be raised regularly to reflect current status.
|
|
59
|
-
|
|
60
|
-
### Testing Libraries
|
|
61
|
-
|
|
62
|
-
- **@testing-library/react** - React component testing
|
|
63
|
-
- **@testing-library/jest-dom** - Custom Jest DOM matchers
|
|
64
|
-
- **@testing-library/user-event** - User interaction simulation
|
|
65
|
-
- **@vitest/coverage-v8** - Code coverage
|
|
66
|
-
- **@vitest/ui** - Interactive test UI
|
|
67
|
-
|
|
68
|
-
## Storybook Testing
|
|
69
|
-
|
|
70
|
-
Every reusable component should have a Storybook story file (`.stories.tsx`).
|
|
71
|
-
|
|
72
|
-
### Story Structure
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
// src/components/product-card/product-card.stories.tsx
|
|
76
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
77
|
-
import { within, expect } from 'storybook/test';
|
|
78
|
-
import { waitForStorybookReady } from '@storybook/test-utils';
|
|
79
|
-
import { ProductCard } from './product-card';
|
|
80
|
-
import { ConfigProvider } from '@/config/context';
|
|
81
|
-
import { mockConfig } from '@/test-utils/config';
|
|
82
|
-
import { mockProduct } from '@/test-utils/mocks';
|
|
83
|
-
|
|
84
|
-
const meta: Meta<typeof ProductCard> = {
|
|
85
|
-
title: 'Components/ProductCard',
|
|
86
|
-
component: ProductCard,
|
|
87
|
-
tags: ['autodocs', 'interaction'],
|
|
88
|
-
decorators: [
|
|
89
|
-
(Story) => (
|
|
90
|
-
<ConfigProvider config={mockConfig}>
|
|
91
|
-
<Story />
|
|
92
|
-
</ConfigProvider>
|
|
93
|
-
),
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export default meta;
|
|
98
|
-
type Story = StoryObj<typeof ProductCard>;
|
|
99
|
-
|
|
100
|
-
export const Default: Story = {
|
|
101
|
-
args: {
|
|
102
|
-
product: mockProduct,
|
|
103
|
-
},
|
|
104
|
-
play: async ({ canvasElement }) => {
|
|
105
|
-
await waitForStorybookReady(canvasElement);
|
|
106
|
-
const canvas = within(canvasElement);
|
|
107
|
-
await expect(canvas.getByText(mockProduct.productName)).toBeInTheDocument();
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Storybook Commands
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
# Development server (port 6006)
|
|
116
|
-
pnpm storybook
|
|
117
|
-
|
|
118
|
-
# Build static Storybook
|
|
119
|
-
pnpm build-storybook
|
|
120
|
-
|
|
121
|
-
# Snapshot tests (visual regression)
|
|
122
|
-
pnpm test-storybook:snapshot
|
|
123
|
-
pnpm test-storybook:snapshot:update # Update snapshots
|
|
124
|
-
|
|
125
|
-
# Interaction tests (play functions)
|
|
126
|
-
pnpm test-storybook:interaction
|
|
127
|
-
pnpm test-storybook:static:interaction # Against static build
|
|
128
|
-
|
|
129
|
-
# Accessibility tests
|
|
130
|
-
pnpm test-storybook:a11y
|
|
131
|
-
pnpm test-storybook:static:a11y # Against static build
|
|
132
|
-
|
|
133
|
-
# Generate story tests with coverage
|
|
134
|
-
pnpm generate:story-tests:coverage
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Storybook Features
|
|
138
|
-
|
|
139
|
-
- **@storybook/addon-docs** - Automatic documentation generation
|
|
140
|
-
- **@storybook/addon-a11y** - Accessibility testing and validation
|
|
141
|
-
- **@storybook/addon-vitest** - Integration with Vitest
|
|
142
|
-
- **@storybook/test-runner** - Automated testing (interaction, a11y)
|
|
143
|
-
- **Viewport Toolbar** - Built-in toolbar for testing different screen sizes
|
|
144
|
-
|
|
145
|
-
> **Important**: Use Storybook's built-in viewport toolbar instead of creating separate Mobile/Tablet/Desktop stories. Use the viewport selector in the Storybook toolbar to test components at different screen sizes.
|
|
146
|
-
|
|
147
|
-
### Story Tags
|
|
148
|
-
|
|
149
|
-
- `autodocs` - Enable automatic documentation
|
|
150
|
-
- `interaction` - Include in interaction test runs
|
|
151
|
-
- `skip-a11y` - Exclude from a11y tests (use sparingly)
|
|
152
|
-
|
|
153
|
-
## Testing Best Practices
|
|
154
|
-
|
|
155
|
-
### Component Testing
|
|
156
|
-
|
|
157
|
-
1. **Colocate tests** - Keep test files next to source files
|
|
158
|
-
2. **Use test utilities** - Leverage `@/test-utils` for mocks and providers
|
|
159
|
-
3. **Mock external dependencies** - Use `vi.mock()` for API clients, context providers, etc.
|
|
160
|
-
4. **Test user interactions** - Use `@testing-library/user-event` for realistic interactions
|
|
161
|
-
5. **Test accessibility** - Use Storybook a11y addon and test-runner
|
|
162
|
-
|
|
163
|
-
### Storybook Stories
|
|
164
|
-
|
|
165
|
-
1. **Multiple variants** - Create stories for different states (Default, Loading, Error, etc.)
|
|
166
|
-
2. **Play functions** - Use `play` functions for interaction testing
|
|
167
|
-
3. **Decorators** - Wrap stories with necessary providers (ConfigProvider, etc.)
|
|
168
|
-
4. **Documentation** - Include component descriptions and prop documentation
|
|
169
|
-
5. **Viewport testing** - Use built-in viewport toolbar, not separate stories
|
|
170
|
-
|
|
171
|
-
### Route Testing
|
|
172
|
-
|
|
173
|
-
Route tests should mock:
|
|
174
|
-
- Loader functions and their return values
|
|
175
|
-
- Action functions
|
|
176
|
-
- React Router context
|
|
177
|
-
- API clients
|
|
178
|
-
|
|
179
|
-
Example:
|
|
180
|
-
|
|
181
|
-
```typescript
|
|
182
|
-
// src/routes/_app.product.$productId.test.tsx
|
|
183
|
-
import { describe, test, expect, vi } from 'vitest';
|
|
184
|
-
import { render } from '@testing-library/react';
|
|
185
|
-
|
|
186
|
-
vi.mock('@/components/product-view', () => ({
|
|
187
|
-
default: ({ product }: any) => (
|
|
188
|
-
<div data-testid="product-view">
|
|
189
|
-
<div data-testid="product-name">{product?.name}</div>
|
|
190
|
-
</div>
|
|
191
|
-
),
|
|
192
|
-
}));
|
|
193
|
-
|
|
194
|
-
// Test route component...
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## Testing Recommendations
|
|
198
|
-
|
|
199
|
-
### SEO Crawler Emulation
|
|
200
|
-
|
|
201
|
-
- Use **Googlebot user agent** in network conditions to emulate SEO crawler behavior
|
|
202
|
-
- This changes React Router's streaming strategy and shows what crawlers see for SSR
|
|
203
|
-
- Helps verify server-side rendering works correctly for search engines
|
|
204
|
-
|
|
205
|
-
### Coverage Goals
|
|
206
|
-
|
|
207
|
-
- Maintain coverage above thresholds defined in `vitest.thresholds.ts`
|
|
208
|
-
- Raise thresholds regularly as coverage improves
|
|
209
|
-
- Focus on testing critical paths and user-facing functionality
|
|
210
|
-
|
|
211
|
-
### Test Organization
|
|
212
|
-
|
|
213
|
-
```
|
|
214
|
-
src/
|
|
215
|
-
├── components/
|
|
216
|
-
│ ├── product-card/
|
|
217
|
-
│ │ ├── index.tsx # Component
|
|
218
|
-
│ │ ├── index.test.tsx # Unit tests
|
|
219
|
-
│ │ └── index.stories.tsx # Storybook stories
|
|
220
|
-
├── routes/
|
|
221
|
-
│ ├── _app.product.$productId.tsx
|
|
222
|
-
│ └── _app.product.$productId.test.tsx
|
|
223
|
-
└── test-utils/ # Shared test utilities
|
|
224
|
-
├── config.ts
|
|
225
|
-
└── context-provider-utils.ts
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
## References
|
|
229
|
-
|
|
230
|
-
- **README-TESTS.md** - Complete testing documentation
|
|
231
|
-
- **.storybook/README-STORYBOOK.md** - Storybook setup and usage guide
|
|
232
|
-
- **vitest.thresholds.ts** - Coverage threshold definitions
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracted parameters from a Figma design URL.
|
|
3
|
-
*
|
|
4
|
-
* @property {string} fileKey - Figma file identifier from URL path
|
|
5
|
-
* @property {string} nodeId - Node identifier (colon format for Figma MCP)
|
|
6
|
-
*/
|
|
7
|
-
export interface FigmaParams {
|
|
8
|
-
fileKey: string;
|
|
9
|
-
nodeId: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Parses a Figma URL to extract fileKey and nodeId.
|
|
13
|
-
*
|
|
14
|
-
* Supported URL formats:
|
|
15
|
-
* - https://figma.com/design/:fileKey/:fileName?node-id=1-2
|
|
16
|
-
* - https://www.figma.com/design/:fileKey/:fileName?node-id=1-2
|
|
17
|
-
* - https://figma.com/file/:fileKey/:fileName?node-id=1-2
|
|
18
|
-
*
|
|
19
|
-
* @param figmaUrl - The Figma URL to parse
|
|
20
|
-
* @returns Object with fileKey and nodeId
|
|
21
|
-
* @throws {Error} When URL is not from figma.com, fileKey cannot be extracted, or node-id is missing
|
|
22
|
-
* @throws {TypeError} When URL format is invalid
|
|
23
|
-
*/
|
|
24
|
-
export declare function parseFigmaUrl(figmaUrl: string): FigmaParams;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2
|
|
4
|
-
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Parses a Figma URL to extract fileKey and nodeId.
|
|
8
|
-
*
|
|
9
|
-
* Supported URL formats:
|
|
10
|
-
* - https://figma.com/design/:fileKey/:fileName?node-id=1-2
|
|
11
|
-
* - https://www.figma.com/design/:fileKey/:fileName?node-id=1-2
|
|
12
|
-
* - https://figma.com/file/:fileKey/:fileName?node-id=1-2
|
|
13
|
-
*
|
|
14
|
-
* @param figmaUrl - The Figma URL to parse
|
|
15
|
-
* @returns Object with fileKey and nodeId
|
|
16
|
-
* @throws {Error} When URL is not from figma.com, fileKey cannot be extracted, or node-id is missing
|
|
17
|
-
* @throws {TypeError} When URL format is invalid
|
|
18
|
-
*/
|
|
19
|
-
export function parseFigmaUrl(figmaUrl) {
|
|
20
|
-
try {
|
|
21
|
-
const url = new URL(figmaUrl);
|
|
22
|
-
// Validate it's a Figma URL
|
|
23
|
-
if (!url.hostname.includes('figma.com')) {
|
|
24
|
-
throw new Error('URL must be from figma.com');
|
|
25
|
-
}
|
|
26
|
-
// Extract fileKey from pathname
|
|
27
|
-
// Pattern: /design/:fileKey/:fileName or /file/:fileKey/:fileName
|
|
28
|
-
const pathMatch = url.pathname.match(/\/(design|file)\/([^/]+)/);
|
|
29
|
-
if (!pathMatch || !pathMatch[2]) {
|
|
30
|
-
throw new Error('Could not extract fileKey from URL. Expected format: https://figma.com/design/:fileKey/:fileName');
|
|
31
|
-
}
|
|
32
|
-
const fileKey = pathMatch[2];
|
|
33
|
-
// Extract nodeId from query params
|
|
34
|
-
// Pattern: ?node-id=1-2 or ?node-id=1:2
|
|
35
|
-
const nodeIdParam = url.searchParams.get('node-id');
|
|
36
|
-
if (!nodeIdParam) {
|
|
37
|
-
throw new Error('Could not extract node-id from URL. Expected query parameter: ?node-id=1-2');
|
|
38
|
-
}
|
|
39
|
-
// Convert node-id format from "1-2" to "1:2" (Figma MCP expects colon format)
|
|
40
|
-
const nodeId = nodeIdParam.replaceAll('-', ':');
|
|
41
|
-
return {
|
|
42
|
-
fileKey,
|
|
43
|
-
nodeId,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
if (error instanceof TypeError) {
|
|
48
|
-
throw new TypeError(`Invalid URL format: ${figmaUrl}`);
|
|
49
|
-
}
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=figma-url-parser.js.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Figma-to-component workflow orchestrator tool.
|
|
3
|
-
*
|
|
4
|
-
* Parses Figma URLs, loads workflow instructions, and returns step-by-step guidance
|
|
5
|
-
* for converting Figma designs to Storefront Next components.
|
|
6
|
-
*
|
|
7
|
-
* @module tools/storefrontnext/figma/figma-to-component
|
|
8
|
-
*/
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import type { McpTool } from '../../../../utils/index.js';
|
|
11
|
-
import type { Services } from '../../../../services.js';
|
|
12
|
-
export declare const figmaToComponentSchema: z.ZodObject<{
|
|
13
|
-
figmaUrl: z.ZodString;
|
|
14
|
-
workflowFilePath: z.ZodOptional<z.ZodString>;
|
|
15
|
-
projectDirectory: z.ZodOptional<z.ZodString>;
|
|
16
|
-
}, "strict", z.ZodTypeAny, {
|
|
17
|
-
figmaUrl: string;
|
|
18
|
-
projectDirectory?: string | undefined;
|
|
19
|
-
workflowFilePath?: string | undefined;
|
|
20
|
-
}, {
|
|
21
|
-
figmaUrl: string;
|
|
22
|
-
projectDirectory?: string | undefined;
|
|
23
|
-
workflowFilePath?: string | undefined;
|
|
24
|
-
}>;
|
|
25
|
-
export type FigmaToComponentInput = z.infer<typeof figmaToComponentSchema>;
|
|
26
|
-
export interface WorkflowConfig {
|
|
27
|
-
/** YAML frontmatter key-value pairs. Parsed for future use (e.g., taskType-specific behavior). */
|
|
28
|
-
metadata: Record<string, string>;
|
|
29
|
-
content: string;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Generates the workflow guide for Figma-to-component conversion.
|
|
33
|
-
*
|
|
34
|
-
* @param figmaUrl - Figma design URL with node-id query parameter
|
|
35
|
-
* @param workflowFilePath - Optional absolute path to custom workflow .md file; uses built-in default if omitted
|
|
36
|
-
* @returns Formatted workflow guide string with Figma parameters and step-by-step instructions, or error message if URL or workflow file is invalid
|
|
37
|
-
*/
|
|
38
|
-
export declare function generateWorkflowResponse(figmaUrl: string, workflowFilePath?: string): string;
|
|
39
|
-
/**
|
|
40
|
-
* Creates the sfnext_start_figma_workflow MCP tool.
|
|
41
|
-
*
|
|
42
|
-
* @param loadServices - Function that loads configuration and returns Services instance
|
|
43
|
-
* @returns MCP tool for workflow orchestration
|
|
44
|
-
*/
|
|
45
|
-
export declare function createFigmaToComponentTool(loadServices: () => Promise<Services> | Services): McpTool;
|