@salesforce/b2c-dx-mcp 0.3.2 → 0.4.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 +47 -27
- package/content/page-designer.md +4 -4
- package/dist/commands/mcp.d.ts +14 -2
- package/dist/commands/mcp.js +21 -9
- package/dist/registry.d.ts +4 -4
- package/dist/registry.js +13 -13
- 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 +20 -6
- package/package.json +10 -5
package/dist/tools/mrt/index.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module tools/mrt
|
|
12
12
|
*/
|
|
13
|
+
import path from 'node:path';
|
|
13
14
|
import { z } from 'zod';
|
|
14
15
|
import { createToolAdapter, jsonResult } from '../adapter.js';
|
|
15
16
|
import { pushBundle } from '@salesforce/b2c-tooling-sdk/operations/mrt';
|
|
@@ -17,20 +18,20 @@ import { getLogger } from '@salesforce/b2c-tooling-sdk/logging';
|
|
|
17
18
|
/**
|
|
18
19
|
* Creates the mrt_bundle_push tool.
|
|
19
20
|
*
|
|
20
|
-
* Creates a bundle from a pre-built PWA Kit project and pushes it to
|
|
21
|
+
* Creates a bundle from a pre-built PWA Kit or Storefront Next project and pushes it to
|
|
21
22
|
* Managed Runtime (MRT). Optionally deploys to a target environment after push.
|
|
22
23
|
* Expects the project to already be built (e.g., `npm run build` completed).
|
|
23
24
|
* Shared across MRT, PWAV3, and STOREFRONTNEXT toolsets.
|
|
24
25
|
*
|
|
25
|
-
* @param
|
|
26
|
+
* @param loadServices - Function that loads configuration and returns Services instance
|
|
26
27
|
* @param injections - Optional dependency injections for testing
|
|
27
28
|
* @returns The mrt_bundle_push tool
|
|
28
29
|
*/
|
|
29
|
-
function createMrtBundlePushTool(
|
|
30
|
+
function createMrtBundlePushTool(loadServices, injections) {
|
|
30
31
|
const pushBundleFn = injections?.pushBundle || pushBundle;
|
|
31
32
|
return createToolAdapter({
|
|
32
33
|
name: 'mrt_bundle_push',
|
|
33
|
-
description: 'Bundle a pre-built PWA Kit project and push to Managed Runtime. Optionally deploy to a target environment.',
|
|
34
|
+
description: 'Bundle a pre-built PWA Kit or Storefront Next project and push to Managed Runtime. Optionally deploy to a target environment.',
|
|
34
35
|
toolsets: ['MRT', 'PWAV3', 'STOREFRONTNEXT'],
|
|
35
36
|
isGA: false,
|
|
36
37
|
// MRT operations use ApiKeyStrategy from SFCC_MRT_API_KEY or ~/.mobify
|
|
@@ -46,6 +47,11 @@ function createMrtBundlePushTool(services, injections) {
|
|
|
46
47
|
.string()
|
|
47
48
|
.optional()
|
|
48
49
|
.describe('Glob patterns for shared files, comma-separated (default: static/**/*,client/**/*)'),
|
|
50
|
+
deploy: z
|
|
51
|
+
.boolean()
|
|
52
|
+
.optional()
|
|
53
|
+
.default(false)
|
|
54
|
+
.describe('Whether to deploy to an environment after push (default: false)'),
|
|
49
55
|
},
|
|
50
56
|
async execute(args, context) {
|
|
51
57
|
// Get project from --project flag (required)
|
|
@@ -54,13 +60,26 @@ function createMrtBundlePushTool(services, injections) {
|
|
|
54
60
|
throw new Error('MRT project error: Project is required. Provide --project flag or set SFCC_MRT_PROJECT environment variable.');
|
|
55
61
|
}
|
|
56
62
|
// Get environment from --environment flag (optional)
|
|
57
|
-
|
|
63
|
+
// When deploy is false, environment is undefined (bundle push only, no deployment)
|
|
64
|
+
// When deploy is true, environment is required
|
|
65
|
+
let environment;
|
|
66
|
+
if (args.deploy) {
|
|
67
|
+
environment = context.mrtConfig?.environment;
|
|
68
|
+
if (!environment) {
|
|
69
|
+
throw new Error('MRT deployment error: Environment is required when deploy=true. ' +
|
|
70
|
+
'Provide --environment flag, set SFCC_MRT_ENVIRONMENT environment variable, or set mrtEnvironment in dw.json.');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
58
73
|
// Get origin from --cloud-origin flag or mrtOrigin config (optional)
|
|
59
74
|
const origin = context.mrtConfig?.origin;
|
|
60
75
|
// Parse comma-separated glob patterns (same as CLI defaults)
|
|
61
76
|
const ssrOnly = (args.ssrOnly || 'ssr.js,ssr.mjs,server/**/*').split(',').map((s) => s.trim());
|
|
62
77
|
const ssrShared = (args.ssrShared || 'static/**/*,client/**/*').split(',').map((s) => s.trim());
|
|
63
|
-
const buildDirectory = args.buildDirectory
|
|
78
|
+
const buildDirectory = args.buildDirectory
|
|
79
|
+
? path.isAbsolute(args.buildDirectory)
|
|
80
|
+
? args.buildDirectory
|
|
81
|
+
: path.resolve(context.services.getWorkingDirectory(), args.buildDirectory)
|
|
82
|
+
: path.join(context.services.getWorkingDirectory(), 'build');
|
|
64
83
|
// Log all computed variables before pushing bundle
|
|
65
84
|
const logger = getLogger();
|
|
66
85
|
logger.debug({
|
|
@@ -86,16 +105,16 @@ function createMrtBundlePushTool(services, injections) {
|
|
|
86
105
|
return result;
|
|
87
106
|
},
|
|
88
107
|
formatOutput: (output) => jsonResult(output),
|
|
89
|
-
},
|
|
108
|
+
}, loadServices);
|
|
90
109
|
}
|
|
91
110
|
/**
|
|
92
111
|
* Creates all tools for the MRT toolset.
|
|
93
112
|
*
|
|
94
|
-
* @param
|
|
113
|
+
* @param loadServices - Function that loads configuration and returns Services instance
|
|
95
114
|
* @param injections - Optional dependency injections for testing
|
|
96
115
|
* @returns Array of MCP tools
|
|
97
116
|
*/
|
|
98
|
-
export function createMrtTools(
|
|
99
|
-
return [createMrtBundlePushTool(
|
|
117
|
+
export function createMrtTools(loadServices, injections) {
|
|
118
|
+
return [createMrtBundlePushTool(loadServices, injections)];
|
|
100
119
|
}
|
|
101
120
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component analysis result
|
|
3
|
+
*/
|
|
4
|
+
export interface ComponentInfo {
|
|
5
|
+
componentName: string;
|
|
6
|
+
interfaceName: null | string;
|
|
7
|
+
hasDecorators: boolean;
|
|
8
|
+
props: PropInfo[];
|
|
9
|
+
exportType: 'default' | 'named';
|
|
10
|
+
filePath: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Property information extracted from component interface
|
|
14
|
+
*/
|
|
15
|
+
export interface PropInfo {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
optional: boolean;
|
|
19
|
+
isComplex: boolean;
|
|
20
|
+
isUIOnly: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Type suggestion for attribute configuration
|
|
24
|
+
*/
|
|
25
|
+
export interface TypeSuggestion {
|
|
26
|
+
type: string;
|
|
27
|
+
reason: string;
|
|
28
|
+
priority: 'high' | 'low' | 'medium';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Valid SFCC Page Designer attribute types
|
|
32
|
+
*/
|
|
33
|
+
export declare const VALID_ATTRIBUTE_TYPES: readonly ["string", "text", "markup", "integer", "boolean", "product", "category", "file", "page", "image", "url", "enum", "custom", "cms_record"];
|
|
34
|
+
/**
|
|
35
|
+
* Infer Page Designer attribute type from TypeScript type
|
|
36
|
+
*/
|
|
37
|
+
export declare function inferPageDesignerType(tsType: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Check if TypeScript type can be auto-inferred
|
|
40
|
+
*/
|
|
41
|
+
export declare function isAutoInferredType(tsType: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if type is too complex for Page Designer
|
|
44
|
+
*/
|
|
45
|
+
export declare function isComplexType(tsType: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Check if property is UI-only
|
|
48
|
+
*/
|
|
49
|
+
export declare function isUIOnlyProp(propName: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Generate Page Designer attribute type suggestions for a component prop
|
|
52
|
+
*
|
|
53
|
+
* **Inference Strategy:**
|
|
54
|
+
* Uses naming patterns and TypeScript types to suggest appropriate Page Designer types.
|
|
55
|
+
* This reduces manual configuration by auto-detecting common patterns.
|
|
56
|
+
*
|
|
57
|
+
* **Page Designer Types:**
|
|
58
|
+
* - `string`: Default text input
|
|
59
|
+
* - `url`: URL/link inputs (validates URL format)
|
|
60
|
+
* - `image`: Image asset picker
|
|
61
|
+
* - `html`: Rich text editor
|
|
62
|
+
* - `markup`: HTML/markdown editor
|
|
63
|
+
* - `enum`: Dropdown with predefined values
|
|
64
|
+
* - `boolean`: Checkbox
|
|
65
|
+
* - `number`: Numeric input
|
|
66
|
+
* - `product`: Product picker (SFCC-specific)
|
|
67
|
+
* - `category`: Category picker (SFCC-specific)
|
|
68
|
+
*
|
|
69
|
+
* **Heuristics (by priority):**
|
|
70
|
+
* 1. **High Priority**: Strong patterns (url, image, product)
|
|
71
|
+
* 2. **Medium Priority**: Contextual patterns (html, markup)
|
|
72
|
+
* 3. **Low Priority**: Weak signals (description → markup)
|
|
73
|
+
*
|
|
74
|
+
* Multiple suggestions allow developers to choose the best fit.
|
|
75
|
+
*
|
|
76
|
+
* @param propName - Property name from component interface
|
|
77
|
+
* @param tsType - TypeScript type string
|
|
78
|
+
* @returns Array of type suggestions with reasoning and priority
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* // URL detection:
|
|
82
|
+
* generateTypeSuggestions('imageUrl', 'string')
|
|
83
|
+
* // => [{ type: 'url', reason: '...', priority: 'high' }]
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* // Image detection:
|
|
87
|
+
* generateTypeSuggestions('heroImage', 'string')
|
|
88
|
+
* // => [{ type: 'image', reason: '...', priority: 'high' }]
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // Multiple suggestions:
|
|
92
|
+
* generateTypeSuggestions('description', 'string')
|
|
93
|
+
* // => [
|
|
94
|
+
* // { type: 'markup', reason: '...', priority: 'low' },
|
|
95
|
+
* // { type: 'html', reason: '...', priority: 'medium' }
|
|
96
|
+
* // ]
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* // Product reference:
|
|
100
|
+
* generateTypeSuggestions('product', 'string')
|
|
101
|
+
* // => [{ type: 'product', reason: '...', priority: 'high' }]
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export declare function generateTypeSuggestions(propName: string, tsType: string): TypeSuggestion[];
|
|
106
|
+
/**
|
|
107
|
+
* Component analyzer for Page Designer decorator generation
|
|
108
|
+
*/
|
|
109
|
+
declare class ComponentAnalyzer {
|
|
110
|
+
private cache;
|
|
111
|
+
analyzeComponent(filePath: string): ComponentInfo;
|
|
112
|
+
clearCache(): void;
|
|
113
|
+
}
|
|
114
|
+
export declare const componentAnalyzer: ComponentAnalyzer;
|
|
115
|
+
/**
|
|
116
|
+
* Resolve component input (name or path) to absolute file path
|
|
117
|
+
*
|
|
118
|
+
* **This is the main entry point for component discovery.**
|
|
119
|
+
*
|
|
120
|
+
* Supports two input modes:
|
|
121
|
+
* 1. **Name-based** (recommended): Just provide the component name
|
|
122
|
+
* 2. **Path-based** (backward compatible): Provide relative path from workspace
|
|
123
|
+
*
|
|
124
|
+
* **Name-based detection:**
|
|
125
|
+
* Input is treated as a name if it:
|
|
126
|
+
* - Does NOT contain path separators (/ or \)
|
|
127
|
+
* - Does NOT have a file extension (.tsx, .ts, etc.)
|
|
128
|
+
*
|
|
129
|
+
* **Path-based detection:**
|
|
130
|
+
* Input is treated as a path if it:
|
|
131
|
+
* - Contains / or \
|
|
132
|
+
* - Has a file extension
|
|
133
|
+
*
|
|
134
|
+
* @param input - Component name or relative path
|
|
135
|
+
* @param workspaceRoot - Absolute path to workspace root
|
|
136
|
+
* @param searchPaths - Additional directories to search (only used for name-based)
|
|
137
|
+
* @returns Absolute file path to component
|
|
138
|
+
* @throws {Error} If component cannot be found, with detailed search information
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* // Name-based (finds automatically):
|
|
142
|
+
* resolveComponent('ProductCard', '/workspace')
|
|
143
|
+
* // => '/workspace/src/components/product-tile/ProductCard.tsx'
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* // Path-based (backward compatible):
|
|
147
|
+
* resolveComponent('src/components/ProductCard.tsx', '/workspace')
|
|
148
|
+
* // => '/workspace/src/components/ProductCard.tsx'
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // With custom search paths (for monorepos):
|
|
152
|
+
* resolveComponent('Hero', '/workspace', ['packages/retail/src', 'packages/shared'])
|
|
153
|
+
* // => '/workspace/packages/retail/src/components/Hero.tsx'
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* // Error handling:
|
|
157
|
+
* try {
|
|
158
|
+
* resolveComponent('NonExistent', '/workspace')
|
|
159
|
+
* } catch (err) {
|
|
160
|
+
* // Error includes:
|
|
161
|
+
* // - List of searched locations
|
|
162
|
+
* // - Tried name variations
|
|
163
|
+
* // - Helpful tips for resolution
|
|
164
|
+
* }
|
|
165
|
+
*
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
export declare function resolveComponent(input: string, workspaceRoot: string, searchPaths?: string[]): string;
|
|
169
|
+
export {};
|