@salesforce/b2c-dx-mcp 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -27
- package/content/page-designer.md +4 -4
- package/dist/commands/mcp.d.ts +12 -0
- package/dist/commands/mcp.js +16 -4
- package/dist/registry.d.ts +4 -4
- package/dist/registry.js +10 -10
- package/dist/services.d.ts +75 -1
- package/dist/services.js +124 -1
- package/dist/tools/adapter.d.ts +29 -21
- package/dist/tools/adapter.js +34 -24
- package/dist/tools/cartridges/index.d.ts +5 -3
- package/dist/tools/cartridges/index.js +55 -25
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/mrt/index.d.ts +2 -2
- package/dist/tools/mrt/index.js +29 -10
- package/dist/tools/page-designer-decorator/analyzer.d.ts +169 -0
- package/dist/tools/page-designer-decorator/analyzer.js +535 -0
- package/dist/tools/page-designer-decorator/index.d.ts +252 -0
- package/dist/tools/page-designer-decorator/index.js +597 -0
- package/dist/tools/page-designer-decorator/rules/1-mode-selection.d.ts +8 -0
- package/dist/tools/page-designer-decorator/rules/1-mode-selection.js +65 -0
- package/dist/tools/page-designer-decorator/rules/2a-auto-mode.d.ts +13 -0
- package/dist/tools/page-designer-decorator/rules/2a-auto-mode.js +87 -0
- package/dist/tools/page-designer-decorator/rules/2b-0-interactive-overview.d.ts +4 -0
- package/dist/tools/page-designer-decorator/rules/2b-0-interactive-overview.js +55 -0
- package/dist/tools/page-designer-decorator/rules/2b-1-interactive-analyze.d.ts +22 -0
- package/dist/tools/page-designer-decorator/rules/2b-1-interactive-analyze.js +109 -0
- package/dist/tools/page-designer-decorator/rules/2b-2-interactive-select-props.d.ts +21 -0
- package/dist/tools/page-designer-decorator/rules/2b-2-interactive-select-props.js +60 -0
- package/dist/tools/page-designer-decorator/rules/2b-3-interactive-configure-attrs.d.ts +27 -0
- package/dist/tools/page-designer-decorator/rules/2b-3-interactive-configure-attrs.js +68 -0
- package/dist/tools/page-designer-decorator/rules/2b-4-interactive-configure-regions.d.ts +4 -0
- package/dist/tools/page-designer-decorator/rules/2b-4-interactive-configure-regions.js +65 -0
- package/dist/tools/page-designer-decorator/rules/2b-5-interactive-confirm-generation.d.ts +11 -0
- package/dist/tools/page-designer-decorator/rules/2b-5-interactive-confirm-generation.js +92 -0
- package/dist/tools/page-designer-decorator/rules.d.ts +51 -0
- package/dist/tools/page-designer-decorator/rules.js +70 -0
- package/dist/tools/page-designer-decorator/templates/decorator-generator.d.ts +116 -0
- package/dist/tools/page-designer-decorator/templates/decorator-generator.js +350 -0
- package/dist/tools/pwav3/index.d.ts +2 -2
- package/dist/tools/pwav3/index.js +13 -13
- package/dist/tools/scapi/index.d.ts +10 -2
- package/dist/tools/scapi/index.js +5 -56
- package/dist/tools/scapi/scapi-custom-apis-status.d.ts +9 -0
- package/dist/tools/scapi/scapi-custom-apis-status.js +152 -0
- package/dist/tools/scapi/scapi-schemas-list.d.ts +12 -0
- package/dist/tools/scapi/scapi-schemas-list.js +248 -0
- package/dist/tools/storefrontnext/developer-guidelines.d.ts +2 -2
- package/dist/tools/storefrontnext/developer-guidelines.js +3 -3
- package/dist/tools/storefrontnext/index.d.ts +2 -2
- package/dist/tools/storefrontnext/index.js +13 -13
- package/oclif.manifest.json +13 -2
- package/package.json +10 -5
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
// Import all rule renderers
|
|
7
|
+
import { renderModeSelection } from './rules/1-mode-selection.js';
|
|
8
|
+
import { renderInteractiveOverview } from './rules/2b-0-interactive-overview.js';
|
|
9
|
+
import { renderAnalyzeStep } from './rules/2b-1-interactive-analyze.js';
|
|
10
|
+
import { renderSelectPropsConfirmation } from './rules/2b-2-interactive-select-props.js';
|
|
11
|
+
import { renderConfigureAttrs } from './rules/2b-3-interactive-configure-attrs.js';
|
|
12
|
+
import { renderConfigureRegions } from './rules/2b-4-interactive-configure-regions.js';
|
|
13
|
+
import { renderConfirmGeneration } from './rules/2b-5-interactive-confirm-generation.js';
|
|
14
|
+
import { renderAutoMode } from './rules/2a-auto-mode.js';
|
|
15
|
+
/**
|
|
16
|
+
* Page Designer decorator rules - type-safe, zero dependencies
|
|
17
|
+
*/
|
|
18
|
+
export const pageDesignerDecoratorRules = {
|
|
19
|
+
/**
|
|
20
|
+
* Renders the mode selection prompt
|
|
21
|
+
*/
|
|
22
|
+
getModeSelectionInstructions(context) {
|
|
23
|
+
return renderModeSelection(context);
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Renders the interactive mode workflow overview
|
|
27
|
+
*/
|
|
28
|
+
getInteractiveOverview() {
|
|
29
|
+
return renderInteractiveOverview();
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Renders Interactive Analyze step instructions
|
|
33
|
+
*/
|
|
34
|
+
getAnalyzeInstructions(context) {
|
|
35
|
+
const workflow = this.getInteractiveOverview();
|
|
36
|
+
const stepContent = renderAnalyzeStep(context);
|
|
37
|
+
return `${workflow}\n\n${stepContent}`;
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Renders Interactive Select Props step confirmation
|
|
41
|
+
*/
|
|
42
|
+
getSelectPropsConfirmation(context) {
|
|
43
|
+
return renderSelectPropsConfirmation(context);
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Renders Interactive Configure Attributes step instructions
|
|
47
|
+
*/
|
|
48
|
+
getConfigureAttrsInstructions(context) {
|
|
49
|
+
return renderConfigureAttrs(context);
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Renders Interactive Configure Regions step instructions
|
|
53
|
+
*/
|
|
54
|
+
getConfigureRegionsInstructions(context) {
|
|
55
|
+
return renderConfigureRegions(context);
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Renders Interactive Confirm Generation step (final code presentation)
|
|
59
|
+
*/
|
|
60
|
+
getConfirmGenerationInstructions(context) {
|
|
61
|
+
return renderConfirmGeneration(context);
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Renders Auto Mode instructions
|
|
65
|
+
*/
|
|
66
|
+
getAutoModeInstructions(context) {
|
|
67
|
+
return renderAutoMode(context);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export interface AttributeContext {
|
|
2
|
+
name: string;
|
|
3
|
+
tsType: string;
|
|
4
|
+
optional: boolean;
|
|
5
|
+
hasConfig: boolean;
|
|
6
|
+
config?: {
|
|
7
|
+
id?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
defaultValue?: unknown;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
values?: string[];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface RegionContext {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
maxComponents?: number;
|
|
21
|
+
componentTypeInclusions?: string[];
|
|
22
|
+
componentTypeExclusions?: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface MetadataContext {
|
|
25
|
+
needsImports: boolean;
|
|
26
|
+
componentId: string;
|
|
27
|
+
componentName: string;
|
|
28
|
+
componentDescription: string;
|
|
29
|
+
componentGroup?: string;
|
|
30
|
+
metadataClassName: string;
|
|
31
|
+
hasAttributes: boolean;
|
|
32
|
+
hasRegions: boolean;
|
|
33
|
+
hasLoader: boolean;
|
|
34
|
+
regions: RegionContext[];
|
|
35
|
+
attributes: AttributeContext[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate complete Page Designer decorator code for a React component
|
|
39
|
+
*
|
|
40
|
+
* **This is the main code generation function.**
|
|
41
|
+
*
|
|
42
|
+
* Produces a TypeScript class with decorators that:
|
|
43
|
+
* 1. Registers the component in Page Designer
|
|
44
|
+
* 2. Defines editable attributes (props)
|
|
45
|
+
* 3. Optionally defines nested content regions
|
|
46
|
+
*
|
|
47
|
+
* **Output structure:**
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { Component } from '...';
|
|
50
|
+
* import { AttributeDefinition } from '...';
|
|
51
|
+
*
|
|
52
|
+
* @Component('component-id', {
|
|
53
|
+
* name: 'Component Name',
|
|
54
|
+
* description: '...',
|
|
55
|
+
* group: 'category'
|
|
56
|
+
* })
|
|
57
|
+
* @RegionDefinition([...]) // Optional
|
|
58
|
+
* export class ComponentMetadata {
|
|
59
|
+
* @AttributeDefinition({ ... })
|
|
60
|
+
* prop1!: string;
|
|
61
|
+
*
|
|
62
|
+
* @AttributeDefinition()
|
|
63
|
+
* prop2?: number;
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* **Generated code must be:**
|
|
68
|
+
* - Added to the component file (after imports, before component)
|
|
69
|
+
* - Compiled with TypeScript
|
|
70
|
+
* - Used by `generate_page_designer_metadata` tool to create JSON metadata
|
|
71
|
+
*
|
|
72
|
+
* @param context - Complete metadata context
|
|
73
|
+
* @returns TypeScript code string ready to paste into component file
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Simple component with attributes:
|
|
77
|
+
* generateDecoratorCode({
|
|
78
|
+
* needsImports: true,
|
|
79
|
+
* componentId: 'hero-banner',
|
|
80
|
+
* componentName: 'Hero Banner',
|
|
81
|
+
* componentDescription: 'Large hero section with image and CTA',
|
|
82
|
+
* componentGroup: 'content',
|
|
83
|
+
* metadataClassName: 'HeroBannerMetadata',
|
|
84
|
+
* hasAttributes: true,
|
|
85
|
+
* hasRegions: false,
|
|
86
|
+
* hasLoader: false,
|
|
87
|
+
* regions: [],
|
|
88
|
+
* attributes: [
|
|
89
|
+
* { name: 'title', tsType: 'string', optional: false, hasConfig: false },
|
|
90
|
+
* { name: 'imageUrl', tsType: 'string', optional: false, hasConfig: true,
|
|
91
|
+
* config: { type: 'image', name: 'Background Image' } }
|
|
92
|
+
* ]
|
|
93
|
+
* })
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* // Layout component with regions:
|
|
97
|
+
* generateDecoratorCode({
|
|
98
|
+
* needsImports: true,
|
|
99
|
+
* componentId: 'two-column',
|
|
100
|
+
* componentName: 'Two Column Layout',
|
|
101
|
+
* componentDescription: 'Side-by-side content layout',
|
|
102
|
+
* componentGroup: 'layout',
|
|
103
|
+
* metadataClassName: 'TwoColumnMetadata',
|
|
104
|
+
* hasAttributes: false,
|
|
105
|
+
* hasRegions: true,
|
|
106
|
+
* hasLoader: false,
|
|
107
|
+
* regions: [
|
|
108
|
+
* { id: 'left', name: 'Left Column' },
|
|
109
|
+
* { id: 'right', name: 'Right Column' }
|
|
110
|
+
* ],
|
|
111
|
+
* attributes: []
|
|
112
|
+
* })
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
export declare function generateDecoratorCode(context: MetadataContext): string;
|
|
@@ -0,0 +1,350 @@
|
|
|
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
|
+
* Generate a simple attribute decorator with auto-inferred type
|
|
8
|
+
*
|
|
9
|
+
* **Simple attributes** use default Page Designer behavior:
|
|
10
|
+
* - Type is inferred from TypeScript type
|
|
11
|
+
* - No custom configuration needed
|
|
12
|
+
* - Minimal decorator syntax
|
|
13
|
+
*
|
|
14
|
+
* **When to use:**
|
|
15
|
+
* - Basic string, number, or boolean props
|
|
16
|
+
* - No special validation or defaults needed
|
|
17
|
+
* - Standard field naming is acceptable
|
|
18
|
+
*
|
|
19
|
+
* @param attr - Attribute context
|
|
20
|
+
* @returns TypeScript code string for the attribute
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Input:
|
|
24
|
+
* { name: 'title', tsType: 'string', optional: false, hasConfig: false }
|
|
25
|
+
*
|
|
26
|
+
* // Output:
|
|
27
|
+
* `@AttributeDefinition()
|
|
28
|
+
* title!: string;`
|
|
29
|
+
*
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
function generateSimpleAttribute(attr) {
|
|
33
|
+
return ` @AttributeDefinition()
|
|
34
|
+
${attr.name}${attr.optional ? '?' : '!'}: ${attr.tsType};`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Generate a configured attribute decorator with explicit settings
|
|
38
|
+
*
|
|
39
|
+
* **Configured attributes** specify custom Page Designer behavior:
|
|
40
|
+
* - Explicit `type` (url, image, enum, etc.)
|
|
41
|
+
* - Custom `name` for display in Page Designer UI
|
|
42
|
+
* - `description` for merchant guidance
|
|
43
|
+
* - `defaultValue` for new instances
|
|
44
|
+
* - `required` flag for validation
|
|
45
|
+
* - `values` array for enum types
|
|
46
|
+
*
|
|
47
|
+
* **When to use:**
|
|
48
|
+
* - URL, image, or rich text fields (need specific editors)
|
|
49
|
+
* - Enum fields with predefined options
|
|
50
|
+
* - Fields with default values
|
|
51
|
+
* - Fields with merchant-friendly names
|
|
52
|
+
*
|
|
53
|
+
* @param attr - Attribute context with configuration
|
|
54
|
+
* @returns TypeScript code string for the configured attribute
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Input (URL field):
|
|
58
|
+
* {
|
|
59
|
+
* name: 'ctaUrl',
|
|
60
|
+
* tsType: 'string',
|
|
61
|
+
* optional: false,
|
|
62
|
+
* hasConfig: true,
|
|
63
|
+
* config: {
|
|
64
|
+
* type: 'url',
|
|
65
|
+
* name: 'CTA Button URL',
|
|
66
|
+
* description: 'Destination URL for the call-to-action button'
|
|
67
|
+
* }
|
|
68
|
+
* }
|
|
69
|
+
*
|
|
70
|
+
* // Output:
|
|
71
|
+
* `@AttributeDefinition({
|
|
72
|
+
* type: 'url',
|
|
73
|
+
* name: 'CTA Button URL',
|
|
74
|
+
* description: 'Destination URL for the call-to-action button',
|
|
75
|
+
* })
|
|
76
|
+
* ctaUrl!: string;`
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // Input (Enum field):
|
|
80
|
+
* {
|
|
81
|
+
* name: 'variant',
|
|
82
|
+
* tsType: 'string',
|
|
83
|
+
* optional: false,
|
|
84
|
+
* hasConfig: true,
|
|
85
|
+
* config: {
|
|
86
|
+
* type: 'enum',
|
|
87
|
+
* name: 'Button Variant',
|
|
88
|
+
* values: ['primary', 'secondary', 'outline'],
|
|
89
|
+
* defaultValue: 'primary'
|
|
90
|
+
* }
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* // Output:
|
|
94
|
+
* `@AttributeDefinition({
|
|
95
|
+
* type: 'enum',
|
|
96
|
+
* name: 'Button Variant',
|
|
97
|
+
* defaultValue: 'primary',
|
|
98
|
+
* values: ['primary', 'secondary', 'outline'],
|
|
99
|
+
* })
|
|
100
|
+
* variant!: string;`
|
|
101
|
+
*
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
function generateConfiguredAttribute(attr) {
|
|
105
|
+
if (!attr.config) {
|
|
106
|
+
return generateSimpleAttribute(attr);
|
|
107
|
+
}
|
|
108
|
+
const config = attr.config;
|
|
109
|
+
const configLines = [];
|
|
110
|
+
if (config.id) {
|
|
111
|
+
configLines.push(` id: '${config.id}',`);
|
|
112
|
+
}
|
|
113
|
+
if (config.name) {
|
|
114
|
+
configLines.push(` name: '${config.name}',`);
|
|
115
|
+
}
|
|
116
|
+
if (config.type) {
|
|
117
|
+
configLines.push(` type: '${config.type}',`);
|
|
118
|
+
}
|
|
119
|
+
if (config.description) {
|
|
120
|
+
configLines.push(` description: '${config.description}',`);
|
|
121
|
+
}
|
|
122
|
+
if (config.defaultValue !== undefined) {
|
|
123
|
+
const valueStr = typeof config.defaultValue === 'string' ? `'${config.defaultValue}'` : JSON.stringify(config.defaultValue);
|
|
124
|
+
configLines.push(` defaultValue: ${valueStr},`);
|
|
125
|
+
}
|
|
126
|
+
if (config.required !== undefined) {
|
|
127
|
+
configLines.push(` required: ${config.required},`);
|
|
128
|
+
}
|
|
129
|
+
if (config.values && config.values.length > 0) {
|
|
130
|
+
configLines.push(` values: [${config.values.map((v) => `'${v}'`).join(', ')}],`);
|
|
131
|
+
}
|
|
132
|
+
return ` @AttributeDefinition({
|
|
133
|
+
${configLines.join('\n')}
|
|
134
|
+
})
|
|
135
|
+
${attr.name}${attr.optional ? '?' : '!'}: ${attr.tsType};`;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Generate import statements for Page Designer decorators
|
|
139
|
+
*
|
|
140
|
+
* **Decision logic:**
|
|
141
|
+
* - Always imports `Component` (required for all decorated components)
|
|
142
|
+
* - Conditionally imports `AttributeDefinition` (if component has editable props)
|
|
143
|
+
* - Conditionally imports `RegionDefinition` (if component has nested content areas)
|
|
144
|
+
*
|
|
145
|
+
* **Why conditional:**
|
|
146
|
+
* Avoids unused imports that would trigger linting warnings.
|
|
147
|
+
*
|
|
148
|
+
* @param context - Metadata context indicating what's needed
|
|
149
|
+
* @returns TypeScript import statements with trailing newlines
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* // Component with attributes only:
|
|
153
|
+
* generateImports({ needsImports: true, hasAttributes: true, hasRegions: false })
|
|
154
|
+
* // => `import { Component } from '@/lib/decorators/component';
|
|
155
|
+
* // import { AttributeDefinition } from '@/lib/decorators/attribute-definition';\n\n`
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* // Component with regions:
|
|
159
|
+
* generateImports({ needsImports: true, hasAttributes: true, hasRegions: true })
|
|
160
|
+
* // => All three decorators imported
|
|
161
|
+
*
|
|
162
|
+
* @internal
|
|
163
|
+
*/
|
|
164
|
+
function generateImports(context) {
|
|
165
|
+
if (!context.needsImports) {
|
|
166
|
+
return '';
|
|
167
|
+
}
|
|
168
|
+
const imports = [`import { Component } from '@/lib/decorators/component';`];
|
|
169
|
+
if (context.hasAttributes) {
|
|
170
|
+
imports.push(`import { AttributeDefinition } from '@/lib/decorators/attribute-definition';`);
|
|
171
|
+
}
|
|
172
|
+
if (context.hasRegions) {
|
|
173
|
+
imports.push(`import { RegionDefinition } from '@/lib/decorators';`);
|
|
174
|
+
}
|
|
175
|
+
return `${imports.join('\n')}\n\n`;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Generate @RegionDefinition decorator for nested content areas
|
|
179
|
+
*
|
|
180
|
+
* **Regions** define areas where merchants can add nested components in Page Designer.
|
|
181
|
+
* Common use cases:
|
|
182
|
+
* - Layout containers (grid cells, columns)
|
|
183
|
+
* - Content sections (header, body, footer)
|
|
184
|
+
* - Tab panels, accordion items
|
|
185
|
+
*
|
|
186
|
+
* **Configuration options:**
|
|
187
|
+
* - `id`: Unique identifier for the region
|
|
188
|
+
* - `name`: Display name in Page Designer
|
|
189
|
+
* - `description`: Merchant guidance
|
|
190
|
+
* - `maxComponents`: Limit number of nested components
|
|
191
|
+
* - `componentTypeInclusions`: Whitelist of allowed component types
|
|
192
|
+
* - `componentTypeExclusions`: Blacklist of disallowed component types
|
|
193
|
+
*
|
|
194
|
+
* @param context - Metadata context with region definitions
|
|
195
|
+
* @returns TypeScript code for @RegionDefinition decorator or empty string
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* // Simple region:
|
|
199
|
+
* {
|
|
200
|
+
* hasRegions: true,
|
|
201
|
+
* regions: [{
|
|
202
|
+
* id: 'main',
|
|
203
|
+
* name: 'Main Content Area',
|
|
204
|
+
* description: 'Add content components here'
|
|
205
|
+
* }]
|
|
206
|
+
* }
|
|
207
|
+
* // => `@RegionDefinition([
|
|
208
|
+
* // {
|
|
209
|
+
* // id: 'main',
|
|
210
|
+
* // name: 'Main Content Area',
|
|
211
|
+
* // description: 'Add content components here',
|
|
212
|
+
* // }
|
|
213
|
+
* // ])\n`
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* // Constrained region:
|
|
217
|
+
* {
|
|
218
|
+
* hasRegions: true,
|
|
219
|
+
* regions: [{
|
|
220
|
+
* id: 'grid',
|
|
221
|
+
* name: 'Product Grid',
|
|
222
|
+
* maxComponents: 12,
|
|
223
|
+
* componentTypeInclusions: ['product-tile', 'product-card']
|
|
224
|
+
* }]
|
|
225
|
+
* }
|
|
226
|
+
*
|
|
227
|
+
* @internal
|
|
228
|
+
*/
|
|
229
|
+
function generateRegionDefinition(context) {
|
|
230
|
+
if (!context.hasRegions || context.regions.length === 0) {
|
|
231
|
+
return '';
|
|
232
|
+
}
|
|
233
|
+
const regionsDef = context.regions
|
|
234
|
+
.map((region) => {
|
|
235
|
+
const lines = [` {`, ` id: '${region.id}',`, ` name: '${region.name}',`];
|
|
236
|
+
if (region.description) {
|
|
237
|
+
lines.push(` description: '${region.description}',`);
|
|
238
|
+
}
|
|
239
|
+
if (region.maxComponents !== undefined) {
|
|
240
|
+
lines.push(` maxComponents: ${region.maxComponents},`);
|
|
241
|
+
}
|
|
242
|
+
if (region.componentTypeInclusions && region.componentTypeInclusions.length > 0) {
|
|
243
|
+
lines.push(` componentTypeInclusions: [${region.componentTypeInclusions.map((t) => `'${t}'`).join(', ')}],`);
|
|
244
|
+
}
|
|
245
|
+
if (region.componentTypeExclusions && region.componentTypeExclusions.length > 0) {
|
|
246
|
+
lines.push(` componentTypeExclusions: [${region.componentTypeExclusions.map((t) => `'${t}'`).join(', ')}],`);
|
|
247
|
+
}
|
|
248
|
+
lines.push(` }`);
|
|
249
|
+
return lines.join('\n');
|
|
250
|
+
})
|
|
251
|
+
.join(',\n');
|
|
252
|
+
return `@RegionDefinition([\n${regionsDef}\n])\n`;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Generate complete Page Designer decorator code for a React component
|
|
256
|
+
*
|
|
257
|
+
* **This is the main code generation function.**
|
|
258
|
+
*
|
|
259
|
+
* Produces a TypeScript class with decorators that:
|
|
260
|
+
* 1. Registers the component in Page Designer
|
|
261
|
+
* 2. Defines editable attributes (props)
|
|
262
|
+
* 3. Optionally defines nested content regions
|
|
263
|
+
*
|
|
264
|
+
* **Output structure:**
|
|
265
|
+
* ```typescript
|
|
266
|
+
* import { Component } from '...';
|
|
267
|
+
* import { AttributeDefinition } from '...';
|
|
268
|
+
*
|
|
269
|
+
* @Component('component-id', {
|
|
270
|
+
* name: 'Component Name',
|
|
271
|
+
* description: '...',
|
|
272
|
+
* group: 'category'
|
|
273
|
+
* })
|
|
274
|
+
* @RegionDefinition([...]) // Optional
|
|
275
|
+
* export class ComponentMetadata {
|
|
276
|
+
* @AttributeDefinition({ ... })
|
|
277
|
+
* prop1!: string;
|
|
278
|
+
*
|
|
279
|
+
* @AttributeDefinition()
|
|
280
|
+
* prop2?: number;
|
|
281
|
+
* }
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* **Generated code must be:**
|
|
285
|
+
* - Added to the component file (after imports, before component)
|
|
286
|
+
* - Compiled with TypeScript
|
|
287
|
+
* - Used by `generate_page_designer_metadata` tool to create JSON metadata
|
|
288
|
+
*
|
|
289
|
+
* @param context - Complete metadata context
|
|
290
|
+
* @returns TypeScript code string ready to paste into component file
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* // Simple component with attributes:
|
|
294
|
+
* generateDecoratorCode({
|
|
295
|
+
* needsImports: true,
|
|
296
|
+
* componentId: 'hero-banner',
|
|
297
|
+
* componentName: 'Hero Banner',
|
|
298
|
+
* componentDescription: 'Large hero section with image and CTA',
|
|
299
|
+
* componentGroup: 'content',
|
|
300
|
+
* metadataClassName: 'HeroBannerMetadata',
|
|
301
|
+
* hasAttributes: true,
|
|
302
|
+
* hasRegions: false,
|
|
303
|
+
* hasLoader: false,
|
|
304
|
+
* regions: [],
|
|
305
|
+
* attributes: [
|
|
306
|
+
* { name: 'title', tsType: 'string', optional: false, hasConfig: false },
|
|
307
|
+
* { name: 'imageUrl', tsType: 'string', optional: false, hasConfig: true,
|
|
308
|
+
* config: { type: 'image', name: 'Background Image' } }
|
|
309
|
+
* ]
|
|
310
|
+
* })
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* // Layout component with regions:
|
|
314
|
+
* generateDecoratorCode({
|
|
315
|
+
* needsImports: true,
|
|
316
|
+
* componentId: 'two-column',
|
|
317
|
+
* componentName: 'Two Column Layout',
|
|
318
|
+
* componentDescription: 'Side-by-side content layout',
|
|
319
|
+
* componentGroup: 'layout',
|
|
320
|
+
* metadataClassName: 'TwoColumnMetadata',
|
|
321
|
+
* hasAttributes: false,
|
|
322
|
+
* hasRegions: true,
|
|
323
|
+
* hasLoader: false,
|
|
324
|
+
* regions: [
|
|
325
|
+
* { id: 'left', name: 'Left Column' },
|
|
326
|
+
* { id: 'right', name: 'Right Column' }
|
|
327
|
+
* ],
|
|
328
|
+
* attributes: []
|
|
329
|
+
* })
|
|
330
|
+
*
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
export function generateDecoratorCode(context) {
|
|
334
|
+
const imports = generateImports(context);
|
|
335
|
+
const componentDecorator = `@Component('${context.componentId}', {
|
|
336
|
+
name: '${context.componentName}',
|
|
337
|
+
description: '${context.componentDescription}',${context.componentGroup ? `\n group: '${context.componentGroup}',` : ''}
|
|
338
|
+
})`;
|
|
339
|
+
const regionDefinition = generateRegionDefinition(context);
|
|
340
|
+
const attributes = context.attributes
|
|
341
|
+
.map((attr) => {
|
|
342
|
+
return attr.hasConfig ? generateConfiguredAttribute(attr) : generateSimpleAttribute(attr);
|
|
343
|
+
})
|
|
344
|
+
.join('\n\n');
|
|
345
|
+
return `${imports}${componentDecorator}
|
|
346
|
+
${regionDefinition}export class ${context.metadataClassName} {
|
|
347
|
+
${attributes}
|
|
348
|
+
}`;
|
|
349
|
+
}
|
|
350
|
+
//# sourceMappingURL=decorator-generator.js.map
|
|
@@ -7,7 +7,7 @@ import type { Services } from '../../services.js';
|
|
|
7
7
|
* toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and will
|
|
8
8
|
* automatically appear in PWAV3.
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
10
|
+
* @param loadServices - Function that loads configuration and returns Services instance
|
|
11
11
|
* @returns Array of MCP tools
|
|
12
12
|
*/
|
|
13
|
-
export declare function createPwav3Tools(
|
|
13
|
+
export declare function createPwav3Tools(loadServices: () => Services): McpTool[];
|
|
@@ -25,10 +25,10 @@ import { createToolAdapter, jsonResult } from '../adapter.js';
|
|
|
25
25
|
* @param name - Tool name
|
|
26
26
|
* @param description - Tool description
|
|
27
27
|
* @param toolsets - Toolsets this tool belongs to
|
|
28
|
-
* @param
|
|
28
|
+
* @param loadServices - Function that loads configuration and returns Services instance
|
|
29
29
|
* @returns The configured MCP tool
|
|
30
30
|
*/
|
|
31
|
-
function createPlaceholderTool(name, description, toolsets,
|
|
31
|
+
function createPlaceholderTool(name, description, toolsets, loadServices) {
|
|
32
32
|
return createToolAdapter({
|
|
33
33
|
name,
|
|
34
34
|
description: `[PLACEHOLDER] ${description}`,
|
|
@@ -50,7 +50,7 @@ function createPlaceholderTool(name, description, toolsets, services) {
|
|
|
50
50
|
};
|
|
51
51
|
},
|
|
52
52
|
formatOutput: (output) => jsonResult(output),
|
|
53
|
-
},
|
|
53
|
+
}, loadServices);
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
56
|
* Creates all tools for the PWAV3 toolset.
|
|
@@ -59,20 +59,20 @@ function createPlaceholderTool(name, description, toolsets, services) {
|
|
|
59
59
|
* toolsets: ["MRT", "PWAV3", "STOREFRONTNEXT"] and will
|
|
60
60
|
* automatically appear in PWAV3.
|
|
61
61
|
*
|
|
62
|
-
* @param
|
|
62
|
+
* @param loadServices - Function that loads configuration and returns Services instance
|
|
63
63
|
* @returns Array of MCP tools
|
|
64
64
|
*/
|
|
65
|
-
export function createPwav3Tools(
|
|
65
|
+
export function createPwav3Tools(loadServices) {
|
|
66
66
|
return [
|
|
67
67
|
// PWA Kit development tools
|
|
68
|
-
createPlaceholderTool('pwakit_create_storefront', 'Create a new PWA Kit storefront project', ['PWAV3'],
|
|
69
|
-
createPlaceholderTool('pwakit_create_page', 'Create a new page component in PWA Kit project', ['PWAV3'],
|
|
70
|
-
createPlaceholderTool('pwakit_create_component', 'Create a new React component in PWA Kit project', ['PWAV3'],
|
|
71
|
-
createPlaceholderTool('pwakit_get_dev_guidelines', 'Get PWA Kit development guidelines and best practices', ['PWAV3'],
|
|
72
|
-
createPlaceholderTool('pwakit_recommend_hooks', 'Recommend appropriate React hooks for PWA Kit use cases', ['PWAV3'],
|
|
73
|
-
createPlaceholderTool('pwakit_run_site_test', 'Run site tests for PWA Kit project', ['PWAV3'],
|
|
74
|
-
createPlaceholderTool('pwakit_install_agent_rules', 'Install AI agent rules for PWA Kit development', ['PWAV3'],
|
|
75
|
-
createPlaceholderTool('pwakit_explore_scapi_shop_api', 'Explore SCAPI Shop API endpoints and capabilities', ['PWAV3'],
|
|
68
|
+
createPlaceholderTool('pwakit_create_storefront', 'Create a new PWA Kit storefront project', ['PWAV3'], loadServices),
|
|
69
|
+
createPlaceholderTool('pwakit_create_page', 'Create a new page component in PWA Kit project', ['PWAV3'], loadServices),
|
|
70
|
+
createPlaceholderTool('pwakit_create_component', 'Create a new React component in PWA Kit project', ['PWAV3'], loadServices),
|
|
71
|
+
createPlaceholderTool('pwakit_get_dev_guidelines', 'Get PWA Kit development guidelines and best practices', ['PWAV3'], loadServices),
|
|
72
|
+
createPlaceholderTool('pwakit_recommend_hooks', 'Recommend appropriate React hooks for PWA Kit use cases', ['PWAV3'], loadServices),
|
|
73
|
+
createPlaceholderTool('pwakit_run_site_test', 'Run site tests for PWA Kit project', ['PWAV3'], loadServices),
|
|
74
|
+
createPlaceholderTool('pwakit_install_agent_rules', 'Install AI agent rules for PWA Kit development', ['PWAV3'], loadServices),
|
|
75
|
+
createPlaceholderTool('pwakit_explore_scapi_shop_api', 'Explore SCAPI Shop API endpoints and capabilities', ['PWAV3'], loadServices),
|
|
76
76
|
];
|
|
77
77
|
}
|
|
78
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SCAPI toolset for B2C Commerce.
|
|
3
|
+
*
|
|
4
|
+
* This toolset provides MCP tools for Salesforce Commerce API (SCAPI) discovery and exploration.
|
|
5
|
+
* Includes both standard SCAPI schemas and custom API status tools.
|
|
6
|
+
*
|
|
7
|
+
* @module tools/scapi
|
|
8
|
+
*/
|
|
1
9
|
import type { McpTool } from '../../utils/index.js';
|
|
2
10
|
import type { Services } from '../../services.js';
|
|
3
11
|
/**
|
|
4
12
|
* Creates all tools for the SCAPI toolset.
|
|
5
13
|
*
|
|
6
|
-
* @param
|
|
14
|
+
* @param loadServices - Function that loads configuration and returns Services instance
|
|
7
15
|
* @returns Array of MCP tools
|
|
8
16
|
*/
|
|
9
|
-
export declare function createScapiTools(
|
|
17
|
+
export declare function createScapiTools(loadServices: () => Services): McpTool[];
|
|
@@ -3,66 +3,15 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2
|
|
4
4
|
* For full license text, see the license.txt file in the repo root or http://www.apache.org/licenses/LICENSE-2.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* This toolset provides MCP tools for Salesforce Commerce API (SCAPI) discovery and exploration.
|
|
10
|
-
*
|
|
11
|
-
* > ⚠️ **PLACEHOLDER - ACTIVE DEVELOPMENT**
|
|
12
|
-
* > Tools in this module are placeholder implementations that return mock responses.
|
|
13
|
-
* > Actual implementations are coming soon. Use `--allow-non-ga-tools` flag to enable.
|
|
14
|
-
*
|
|
15
|
-
* @module tools/scapi
|
|
16
|
-
*/
|
|
17
|
-
import { z } from 'zod';
|
|
18
|
-
import { createToolAdapter, jsonResult } from '../adapter.js';
|
|
19
|
-
/**
|
|
20
|
-
* Creates a placeholder tool for SCAPI operations.
|
|
21
|
-
*
|
|
22
|
-
* Placeholder tools log invocations and return mock responses until
|
|
23
|
-
* the actual implementation is available.
|
|
24
|
-
*
|
|
25
|
-
* @param name - Tool name
|
|
26
|
-
* @param description - Tool description
|
|
27
|
-
* @param toolsets - Toolsets this tool belongs to
|
|
28
|
-
* @param services - MCP services
|
|
29
|
-
* @returns The configured MCP tool
|
|
30
|
-
*/
|
|
31
|
-
function createPlaceholderTool(name, description, toolsets, services) {
|
|
32
|
-
return createToolAdapter({
|
|
33
|
-
name,
|
|
34
|
-
description: `[PLACEHOLDER] ${description}`,
|
|
35
|
-
toolsets,
|
|
36
|
-
isGA: false,
|
|
37
|
-
requiresInstance: true,
|
|
38
|
-
inputSchema: {
|
|
39
|
-
message: z.string().optional().describe('Optional message to echo'),
|
|
40
|
-
},
|
|
41
|
-
async execute(args) {
|
|
42
|
-
// Placeholder implementation
|
|
43
|
-
const timestamp = new Date().toISOString();
|
|
44
|
-
return {
|
|
45
|
-
tool: name,
|
|
46
|
-
status: 'placeholder',
|
|
47
|
-
message: `This is a placeholder implementation for '${name}'. The actual implementation is coming soon.`,
|
|
48
|
-
input: args,
|
|
49
|
-
timestamp,
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
formatOutput: (output) => jsonResult(output),
|
|
53
|
-
}, services);
|
|
54
|
-
}
|
|
6
|
+
import { createScapiSchemasListTool } from './scapi-schemas-list.js';
|
|
7
|
+
import { createScapiCustomApisStatusTool } from './scapi-custom-apis-status.js';
|
|
55
8
|
/**
|
|
56
9
|
* Creates all tools for the SCAPI toolset.
|
|
57
10
|
*
|
|
58
|
-
* @param
|
|
11
|
+
* @param loadServices - Function that loads configuration and returns Services instance
|
|
59
12
|
* @returns Array of MCP tools
|
|
60
13
|
*/
|
|
61
|
-
export function createScapiTools(
|
|
62
|
-
return [
|
|
63
|
-
createPlaceholderTool('scapi_discovery', 'Discover available SCAPI endpoints and capabilities', ['PWAV3', 'SCAPI', 'STOREFRONTNEXT'], services),
|
|
64
|
-
createPlaceholderTool('scapi_customapi_scaffold', 'Scaffold a new custom SCAPI API', ['SCAPI'], services),
|
|
65
|
-
createPlaceholderTool('scapi_custom_api_discovery', 'Discover custom SCAPI API endpoints', ['PWAV3', 'SCAPI', 'STOREFRONTNEXT'], services),
|
|
66
|
-
];
|
|
14
|
+
export function createScapiTools(loadServices) {
|
|
15
|
+
return [createScapiSchemasListTool(loadServices), createScapiCustomApisStatusTool(loadServices)];
|
|
67
16
|
}
|
|
68
17
|
//# sourceMappingURL=index.js.map
|