sfcc-dev-mcp 1.0.22 → 1.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +73 -4
  2. package/README.md +25 -4
  3. package/dist/ai-instructions/skills/sfcc-script-evaluation/SKILL.md +1 -0
  4. package/dist/clients/script-debugger/script-debugger-client.d.ts +21 -0
  5. package/dist/clients/script-debugger/script-debugger-client.d.ts.map +1 -1
  6. package/dist/clients/script-debugger/script-debugger-client.js +88 -9
  7. package/dist/clients/script-debugger/script-debugger-client.js.map +1 -1
  8. package/dist/config/configuration-factory.d.ts +2 -0
  9. package/dist/config/configuration-factory.d.ts.map +1 -1
  10. package/dist/config/configuration-factory.js +18 -0
  11. package/dist/config/configuration-factory.js.map +1 -1
  12. package/dist/config/dw-json-loader.d.ts.map +1 -1
  13. package/dist/config/dw-json-loader.js +6 -0
  14. package/dist/config/dw-json-loader.js.map +1 -1
  15. package/dist/core/tool-schemas/script-debugger-tools.d.ts +5 -0
  16. package/dist/core/tool-schemas/script-debugger-tools.d.ts.map +1 -1
  17. package/dist/core/tool-schemas/script-debugger-tools.js +10 -0
  18. package/dist/core/tool-schemas/script-debugger-tools.js.map +1 -1
  19. package/dist/docs/dw_extensions.payments/SalesforcePaymentsMgr.md +52 -0
  20. package/dist/docs/dw_system/Request.md +4 -0
  21. package/dist/docs/dw_web/Cookie.md +54 -15
  22. package/dist/tool-configs/script-debugger-tool-config.d.ts.map +1 -1
  23. package/dist/tool-configs/script-debugger-tool-config.js +1 -0
  24. package/dist/tool-configs/script-debugger-tool-config.js.map +1 -1
  25. package/dist/types/types.d.ts +9 -1
  26. package/dist/types/types.d.ts.map +1 -1
  27. package/dist/utils/abort-utils.d.ts.map +1 -1
  28. package/dist/utils/abort-utils.js +6 -0
  29. package/dist/utils/abort-utils.js.map +1 -1
  30. package/dist/utils/cache.d.ts.map +1 -1
  31. package/dist/utils/cache.js +1 -0
  32. package/dist/utils/cache.js.map +1 -1
  33. package/package.json +14 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a0f5fbb: Add script debugger support for credentialed troubleshooting, including dedicated storefront authentication and custom trigger URLs.
8
+
9
+ Improve MCP execution and configuration handling with progress notifications, request cancellation, runtime WebDAV capability checks, flexible `dw.json` authentication, strict tool argument validation, and structured timeout-aware tool results.
10
+
11
+ Strengthen overall reliability with broader documentation and skill guidance, stronger tests and post-publish validation, and robustness improvements across the server, handlers, and configuration pipeline.
12
+
3
13
  All notable changes to this project will be documented in this file.
4
14
 
5
15
  The format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
@@ -7,8 +17,10 @@ The format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.
7
17
  Release comparison links are provided at the bottom. Earlier patch releases on the same day may represent rapid iterations (e.g. architectural + documentation expansions). Dates are derived from git tag timestamps.
8
18
 
9
19
  ## [1.0.15] - 2025-10-03
20
+
10
21
  ### Added
11
- - **SFRA Best Practices Expansion**:
22
+
23
+ - **SFRA Best Practices Expansion**:
12
24
  - SFRA SCSS best practices guide with theming and override patterns
13
25
  - SFRA client-side JavaScript guide covering AJAX flows, validation, and accessibility
14
26
  - **OCAPI Select Parameter Support**: Comprehensive support for OCAPI select syntax to control response field selection
@@ -25,6 +37,7 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
25
37
  - **Custom Endpoint Caching**: Comprehensive caching strategies documentation for custom SCAPI endpoints with two-tier pattern examples
26
38
 
27
39
  ### Changed
40
+
28
41
  - **Testing Framework Migration**: Replaced Conductor with Aegis for MCP testing with improved declarative YAML patterns
29
42
  - **Documentation Modernization**:
30
43
  - Revamped documentation site with improved layout and readability
@@ -41,16 +54,19 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
41
54
  - **AI Interface Enhancements**: Improved AI interface and configuration documentation
42
55
 
43
56
  ### Fixed
57
+
44
58
  - **SSR Hydration**: Fixed SSR hydration mismatch in OnThisPage component
45
59
  - **Hash Navigation**: Resolved hash navigation issues after search operations
46
60
 
47
61
  ### Documentation
62
+
48
63
  - **CSRF Middleware**: Clarified CSRF middleware usage patterns in SFRA
49
64
  - **Remote Include Architecture**: Added detailed explanation of remote include patterns for dynamic content
50
65
  - **Aegis Testing**: Comprehensive updates to Aegis testing documentation with best practices
51
66
  - **Performance Guidance**: Enhanced performance best practices with SCAPI-specific caching strategies
52
67
 
53
68
  ### Testing
69
+
54
70
  - **Comprehensive Test Coverage**:
55
71
  - OCAPI error handling and validation tests
56
72
  - Site preferences search tool tests
@@ -64,6 +80,7 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
64
80
  - Enhanced test targeting and organization
65
81
 
66
82
  ### Dependencies
83
+
67
84
  - **GitHub Actions Updates**:
68
85
  - `actions/checkout` from 4 to 5
69
86
  - `actions/configure-pages` from 4 to 5
@@ -77,16 +94,19 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
77
94
  - Updated `ts-jest` in Jest group
78
95
 
79
96
  ### Notes
97
+
80
98
  - Major testing infrastructure modernization with Aegis framework adoption
81
99
  - Significant documentation site improvements with SSG migration and enhanced UX
82
100
  - Expanded SFRA best practices coverage for complete development lifecycle
83
101
  - Enhanced OCAPI functionality with select parameter support and comprehensive mocking
84
102
 
85
103
  ## [1.0.14] - 2025-09-16
104
+
86
105
  ### Added
106
+
87
107
  - **SFCC Class Information Filtering**: Enhanced `get_sfcc_class_info` tool with comprehensive filtering capabilities including search parameter, inclusion/exclusion of descriptions, constants, properties, methods, and inheritance hierarchy.
88
108
  - **AI Response Comparison Modals**: Interactive modals on documentation site showing side-by-side comparison of AI responses with and without MCP server, including zoom functionality for detailed inspection.
89
- - **Documentation Site Enhancements**:
109
+ - **Documentation Site Enhancements**:
90
110
  - Examples page with practical usage scenarios and filtering demonstrations
91
111
  - Tools page documenting all available MCP tools
92
112
  - Features page highlighting key capabilities
@@ -99,6 +119,7 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
99
119
  - **Anchor Link Navigation**: Added IDs to documentation headers for direct linking.
100
120
 
101
121
  ### Changed
122
+
102
123
  - **Project Licensing**: Aligned to MIT License (replaced ISC LICENSE text, updated `package.json` license field).
103
124
  - **CI/CD Pipeline**: Enhanced with improved linting and security checks.
104
125
  - **Documentation Structure**: Comprehensive reorganization and expansion of documentation site structure.
@@ -107,152 +128,199 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
107
128
  - **UI/UX Polish**: Improved padding, layout adjustments, and site navigation structure.
108
129
 
109
130
  ### Fixed
131
+
110
132
  - **URL Fragment Handling**: Fixed URL-encoded hash fragment handling in documentation site.
111
133
  - **Workflow Deployment**: Corrected path issues for page deployment.
112
134
  - **Log Tool Validation**: Improved argument validation robustness for log analysis tools.
113
135
 
114
136
  ### Documentation
137
+
115
138
  - **AI Interface Setup**: Comprehensive guides for Claude Desktop, Cursor, and GitHub Copilot integration.
116
139
  - **Security Guidance**: Enhanced security considerations and best practices documentation.
117
140
  - **Troubleshooting**: Added comprehensive troubleshooting guide for common setup and usage issues.
118
141
  - **Development Workflow**: Detailed development guidelines and contribution instructions.
119
142
 
120
143
  ### Testing
121
- - **Enhanced Test Coverage**:
144
+
145
+ - **Enhanced Test Coverage**:
122
146
  - Comprehensive programmatic tests for SFCC class info filtering in documentation mode
123
147
  - Enhanced YAML-based MCP tests for class information tools
124
148
  - Job execution summary tests and job log analysis tests
125
149
  - Improved test setup reliability and CI stability
126
150
 
127
151
  ### Notes
152
+
128
153
  - Major documentation site expansion with React/Vite architecture
129
154
  - Enhanced developer experience with comprehensive filtering and search capabilities
130
155
  - Improved AI assistant integration with detailed setup guides for multiple platforms
131
156
 
132
157
  ## [1.0.13] - 2025-09-15
158
+
133
159
  ### Added
160
+
134
161
  - `engines` field in `package.json` enforcing Node >=18 and npm >=8.
135
162
  - Comprehensive architectural documentation (handler modularization, capability gating, services layer, log subsystem, tool-configs, caching).
136
163
  - Initial `CHANGELOG.md` introduction.
137
164
 
138
165
  ### Changed
166
+
139
167
  - Server reported version synchronized with `package.json`.
140
168
  - Development guide: migrated from legacy Jekyll instructions to Vite workflow; updated tool addition workflow for new handler architecture.
141
169
 
142
170
  ### Fixed
171
+
143
172
  - Removed references to non-existent config files (`config.ts`, `constants.ts`).
144
173
  - Corrected debug flag examples (`--debug` vs `--debug true`).
145
174
  - Escaping/format fixes in development guide code blocks.
146
175
 
147
176
  ### Notes
177
+
148
178
  - Pre-1.0.14 license mismatch (ISC vs MIT badge) resolved in 1.0.14.
149
179
 
150
180
  ## [1.0.12] - 2025-08-19
181
+
151
182
  ### Added
183
+
152
184
  - Code version management tools (listing & activation) with supporting documentation.
153
185
  - Cartridge generation enhancements: page layout & styling improvements; prevention of overwriting existing files.
154
186
  - Security and OCAPI configuration warnings; highlighted AI instruction files.
155
187
  - Additional SFRA model and best practice documentation (ISML decorators, LocalServiceRegistry, Auth examples, BM configuration guide).
156
188
 
157
189
  ### Changed
190
+
158
191
  - ESLint configuration (global vars, lint fix script), table styling, documentation site theme updates, repository URL in config, branch protection for deploy (restricted to main), improved instance type check.
159
192
  - Documentation structure reorganized (multiple passes consolidating guides, theme adjustments, layout evolution and subsequent refinements / reverts).
160
193
 
161
194
  ### Fixed
195
+
162
196
  - Removal of `resourceState` from activateCodeVersion request.
163
197
 
164
198
  ### Documentation
199
+
165
200
  - Large expansion of SFRA models, cartridge creation, ISML templates, decorators warnings, URL patterns, customer context, authentication flows, endpoint security guidance.
166
201
 
167
202
  ### Notes
203
+
168
204
  - Multiple rapid doc iterations (additions, reverts, restyles) before stabilization.
169
205
 
170
206
  ## [1.0.11] - 2025-08-15
207
+
171
208
  ### Added
209
+
172
210
  - SFCC development rules and SFRA controllers best practices guide.
173
211
  - AI interface instruction documentation.
174
212
 
175
213
  ### Changed
214
+
176
215
  - Refactored rule configurations; enhanced SFCC debugging workflows; streamlined documentation tools; removed improvement roadmap.
177
216
 
178
217
  ### Fixed
218
+
179
219
  - Log files now sorted by last modification for accurate recency ordering.
180
220
 
181
221
  ### Testing
222
+
182
223
  - Enhanced log client test coverage.
183
224
 
184
225
  ### Notes
226
+
185
227
  - Documentation emphasis on rule context explanation and operational clarity.
186
228
 
187
229
  ## [1.0.10] - 2025-08-15
230
+
188
231
  ### Added
232
+
189
233
  - Custom object attribute search capability.
190
234
  - Progressive development guide (subsequently refined) and job framework best practices.
191
235
  - Additional documentation: steptypes configuration, ISML templates, SCAPI custom endpoint guide, path parameter & search query usage clarifications, SFRA documentation support expansion.
192
236
 
193
237
  ### Changed
238
+
194
239
  - Auth examples refactored into appendix; logging improvements and build output cleanliness.
195
240
 
196
241
  ### Fixed
242
+
197
243
  - Reversal / clarification cycles for job framework status codes and default values (cleanup of earlier docs ambiguities).
198
244
 
199
245
  ### Notes
246
+
200
247
  - Foundation for expanded SCAPI / SFRA documentation just before rapid rule & controller additions in 1.0.11.
201
248
 
202
249
  ## [1.0.9-2] - 2025-08-13
250
+
203
251
  ### Changed
252
+
204
253
  - Enhanced release workflow (iteration on same-day release of 1.0.9).
205
254
 
206
255
  ## [1.0.9] - 2025-08-13
256
+
207
257
  ### Added
258
+
208
259
  - Initial modular handler & directory architecture groundwork: secure config loading, debug log support, documentation-only mode, system object exposure, site preferences & attribute search, OCAPI client integration.
209
260
  - CI workflow, caching layer for documentation, expanded class details, path resolver, pre-commit hooks, NPM publishing & Dependabot configuration, issue templates.
210
261
 
211
262
  ### Changed
263
+
212
264
  - Large-scale codebase reorganization (directory structure, authentication & logging refactors, configuration loading improvements, handler refactors, OAuth token management relocation, package metadata updates, JSON serialization, system object description refinements, server architecture refactor).
213
265
  - Log tool naming alignment & tool description clarity improvements.
214
266
 
215
267
  ### Fixed
268
+
216
269
  - File path security validation enhancements.
217
270
 
218
271
  ### Documentation
272
+
219
273
  - Extensive expansion: best practices (security, performance, cartridge creation), contributing guidelines, search tool description, quick setup, system object definitions, Copilot instructions, local dev focus clarification.
220
274
 
221
275
  ### Testing
276
+
222
277
  - Added Jest framework and early test coverage (config factory, OAuth token manager, log client, attribute definitions, best practices client).
223
278
 
224
279
  ### Notes
280
+
225
281
  - Represents the foundational public baseline preceding rapid feature layering in 1.0.10+.
226
282
 
227
283
  ## [1.0.8] - 2025-08-13
284
+
228
285
  ### Changed
286
+
229
287
  - Package version alignment & metadata updates; project structure and documentation improvements; Node version CI expansions.
230
288
 
231
289
  ### Added
290
+
232
291
  - Security & performance best practices guides, contributing guidelines, AI assistant integration guide, deprecation support, attribute definition search, site preferences search.
233
292
 
234
293
  ### Notes
294
+
235
295
  - Last pre-architecture refactor baseline before major handler and structural reorganization in 1.0.9.
236
296
 
237
297
  ## [1.0.2] - 2025-08-08
298
+
238
299
  ### Added
300
+
239
301
  - Debug logging capabilities, caching for documentation, expanded class details, initial SFCC MCP server feature set (system object & attribute tools, OCAPI integration, documentation retrieval).
240
302
  - Jest testing framework & initial unit tests.
241
303
 
242
304
  ### Changed
305
+
243
306
  - Centralized logging infrastructure; configuration logging & security tightening; authentication config refactors.
244
307
 
245
308
  ### Documentation
309
+
246
310
  - Cartridge creation guide, npx usage instructions, API docs, system object definitions resource.
247
311
 
248
312
  ### Notes
313
+
249
314
  - Early stabilization phase; intermediate patch releases between 1.0.2 and 1.0.8 consolidated here (internal iteration without tags not reconstructed individually).
250
315
 
251
316
  ## [1.0.0] - 2025-08-08
317
+
252
318
  ### Added
319
+
253
320
  - Initial commit introducing SFCC Dev MCP Server core (base server, tooling scaffolding, initial documentation framework).
254
321
 
255
322
  ### Notes
323
+
256
324
  - Foundation commit history includes scaffolding, early capability extensions, and initial architectural decisions.
257
325
 
258
326
  ---
@@ -260,6 +328,7 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
260
328
  ---
261
329
 
262
330
  ### Future
331
+
263
332
  - Add automation for changelog validation in CI (ensure categories & links present).
264
333
  - Add script to generate comparison links automatically when tagging.
265
334
  - Potential provenance notes for security-impacting changes (e.g., file path validation hardening).
@@ -267,6 +336,7 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
267
336
  ---
268
337
 
269
338
  ### Comparison Links
339
+
270
340
  [1.0.15]: https://github.com/taurgis/sfcc-dev-mcp/compare/v1.0.14...v1.0.15
271
341
  [1.0.14]: https://github.com/taurgis/sfcc-dev-mcp/compare/v1.0.13...v1.0.14
272
342
  [1.0.13]: https://github.com/taurgis/sfcc-dev-mcp/compare/v1.0.12...v1.0.13
@@ -278,4 +348,3 @@ Release comparison links are provided at the bottom. Earlier patch releases on t
278
348
  [1.0.8]: https://github.com/taurgis/sfcc-dev-mcp/compare/v1.0.2...v1.0.8
279
349
  [1.0.2]: https://github.com/taurgis/sfcc-dev-mcp/compare/v1.0.0...v1.0.2
280
350
  [1.0.0]: https://github.com/taurgis/sfcc-dev-mcp/tree/v1.0.0
281
-
package/README.md CHANGED
@@ -12,7 +12,7 @@ An AI-powered Model Context Protocol (MCP) server that provides comprehensive ac
12
12
  - **🧱 ISML Template Reference** - Complete ISML element documentation with examples and usage guidance
13
13
  - **📊 Log Analysis Tools** - Real-time error monitoring, debugging, and job log analysis for SFCC instances
14
14
  - **⚙️ System Object Definitions** - Explore custom attributes and site preferences
15
- - **🧪 Script Debugger** - Execute and inspect script-debugger endpoints in credentialed mode
15
+ - **🧪 Script Debugger** - Execute and inspect script-debugger endpoints in credentialed mode, including custom trigger URLs/paths for non-default storefront routes
16
16
  - **🚀 Cartridge Generation** - Automated cartridge structure creation with workspace-bound path safety (writes stay inside workspace roots, or current working directory fallback when roots are unavailable; home-directory fallback is blocked)
17
17
  - **🧩 Agent Skill Bootstrap** - Install or merge AGENTS.md and bundled skills into the current project or a temp directory for AI assistants
18
18
  - **✅ Tool Argument Validation** - Runtime schema validation enforces required fields, type checks, enum constraints, integer/numeric bounds, and strict unknown-key checks for object schemas (top-level and nested) before handler execution
@@ -47,11 +47,14 @@ An AI-powered Model Context Protocol (MCP) server that provides comprehensive ac
47
47
  Create a `dw.json` file with your SFCC credentials. You can use either auth mode (or both):
48
48
  - Basic auth: `username` + `password`
49
49
  - OAuth: `client-id` + `client-secret`
50
+ - Optional storefront auth (for script debugger trigger on Basic-Auth storefronts): `storefrontUsername` + `storefrontPassword`
50
51
  ```json
51
52
  {
52
53
  "hostname": "your-instance.sandbox.us01.dx.commercecloud.salesforce.com",
53
54
  "username": "your-username",
54
- "password": "your-password",
55
+ "password": "your-password",
56
+ "storefrontUsername": "your-storefront-basic-user",
57
+ "storefrontPassword": "your-storefront-basic-password",
55
58
  "client-id": "your-client-id",
56
59
  "client-secret": "your-client-secret"
57
60
  }
@@ -210,9 +213,27 @@ The server writes logs to your system's temporary directory:
210
213
  node -e "console.log(require('os').tmpdir() + '/sfcc-mcp-logs')"
211
214
  ```
212
215
 
213
- ## 🧪 Release Validation (Maintainers)
216
+ ## 🧪 Release Flow (Maintainers)
214
217
 
215
- The publish workflow runs MCP tests against the just-published npm artifact (`npx sfcc-dev-mcp@<version>`) before publishing to the MCP Registry.
218
+ This repository now uses Changesets for npm releases.
219
+
220
+ When a change should ship in a new `sfcc-dev-mcp` version, add a changeset from the repository root:
221
+
222
+ ```bash
223
+ npm run changeset
224
+ ```
225
+
226
+ Check pending release state against `main` before merging:
227
+
228
+ ```bash
229
+ npm run release:status
230
+ ```
231
+
232
+ The release workflow on `main` creates or updates a release pull request from pending changesets. Merging that release pull request publishes the npm package through npm trusted publishing (GitHub Actions OIDC), waits for npm propagation, reruns MCP tests against the published NPX artifact, and then publishes the same version to the MCP Registry.
233
+
234
+ `npm run version-packages` also syncs `server.json` with the package version so `validate:server-json` keeps passing in the release PR.
235
+
236
+ Package publication now uses GitHub Actions OIDC trusted publishing, so no separate npm publish secret is required.
216
237
 
217
238
  You can run the same validation locally:
218
239
 
@@ -27,6 +27,7 @@ The `evaluate_script` tool allows you to execute arbitrary JavaScript code on an
27
27
  | `timeout` | No | `30000` | Maximum execution time in milliseconds |
28
28
  | `breakpointFile` | No | Auto-detected | Custom controller path for breakpoint |
29
29
  | `breakpointLine` | No | `1,10,20,30,40,50` | Specific line for a single breakpoint; if omitted, strategic lines (1,10,20,30,40,50) are used |
30
+ | `triggerUrl` | No | Auto-detected | Custom storefront URL or path to trigger; site-relative paths are resolved to `https://{hostname}/s/{siteId}/...` |
30
31
 
31
32
  ## Script Syntax Rules
32
33
 
@@ -64,6 +64,7 @@ export declare class ScriptDebuggerClient {
64
64
  locale?: string;
65
65
  breakpointFile?: string;
66
66
  breakpointLine?: number;
67
+ triggerUrl?: string;
67
68
  }): Promise<ScriptEvaluationResult>;
68
69
  private enqueueSerializedEvaluation;
69
70
  private resolveCartridgeConfig;
@@ -74,6 +75,16 @@ export declare class ScriptDebuggerClient {
74
75
  * Build and cache authentication header for debugger API
75
76
  */
76
77
  private getAuthHeader;
78
+ /**
79
+ * Build auth header for storefront trigger requests.
80
+ *
81
+ * Preference order:
82
+ * 1) Dedicated storefront credentials from dw.json
83
+ * 2) Primary basic auth credentials (username/password)
84
+ *
85
+ * OAuth credentials are intentionally not sent to storefront routes.
86
+ */
87
+ private getStorefrontTriggerAuthHeader;
77
88
  /**
78
89
  * Get WebDAV client credentials
79
90
  */
@@ -112,6 +123,16 @@ export declare class ScriptDebuggerClient {
112
123
  * Normalize locale value by trimming and removing leading/trailing slashes
113
124
  */
114
125
  private normalizeLocale;
126
+ /**
127
+ * Resolve a storefront trigger input into a fully-qualified URL for the configured instance.
128
+ *
129
+ * Supported forms:
130
+ * - Full URL (https://hostname/...)
131
+ * - Hostname-prefixed URL without scheme (hostname/...)
132
+ * - Absolute path (/on/demandware.store/... or /s/...)
133
+ * - Site-relative path (/womens/?lang=en_US -> /s/{siteId}/womens/?lang=en_US)
134
+ */
135
+ private resolveTriggerUrl;
115
136
  /**
116
137
  * Trigger the Default-Start endpoint via HTTP
117
138
  */
@@ -1 +1 @@
1
- {"version":3,"file":"script-debugger-client.d.ts","sourceRoot":"","sources":["../../../src/clients/script-debugger/script-debugger-client.ts"],"names":[],"mappings":"AAAA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hB,sBAAsB;IAgBpC;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;OAEG;YACW,gBAAgB;IAkB9B;;;OAGG;YACW,yBAAyB;IAiBvC;;OAEG;YACW,eAAe;IAoE7B;;OAEG;YACW,cAAc;IA8B5B;;;OAGG;YACW,cAAc;IAkC5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAKvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;YACW,mBAAmB;IAyBjC;;;;;OAKG;YACW,oBAAoB;IAuClC;;OAEG;YACW,mBAAmB;IA8CjC;;OAEG;YACW,iBAAiB;IAiB/B;;OAEG;YACW,YAAY;IAa1B;;OAEG;YACW,OAAO;IAcf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2BxB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAiBvE"}
1
+ {"version":3,"file":"script-debugger-client.d.ts","sourceRoot":"","sources":["../../../src/clients/script-debugger/script-debugger-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAqBlD;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAsED;;;;;;;;;;;;GAYG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAA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,CAAC,eAAe;IAMvB;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAuCzB;;OAEG;YACW,mBAAmB;IAkCjC;;;;;OAKG;YACW,oBAAoB;IA6ClC;;OAEG;YACW,mBAAmB;IA8CjC;;OAEG;YACW,iBAAiB;IAiB/B;;OAEG;YACW,YAAY;IAa1B;;OAEG;YACW,OAAO;IAcf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAO9B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2BxB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAiBvE"}
@@ -88,6 +88,7 @@ export class ScriptDebuggerClient {
88
88
  const timeout = options.timeout ?? DEFAULT_TIMEOUT_MS;
89
89
  const siteId = options.siteId ?? DEFAULT_SITE_ID;
90
90
  const locale = this.normalizeLocale(options.locale ?? DEFAULT_LOCALE);
91
+ const normalizedSiteId = this.normalizeSiteId(siteId);
91
92
  const warnings = [];
92
93
  this.logger.debug('Starting script evaluation', {
93
94
  scriptLength: script.length,
@@ -96,6 +97,9 @@ export class ScriptDebuggerClient {
96
97
  customBreakpoint: options.breakpointFile ? `${options.breakpointFile}:${options.breakpointLine}` : undefined,
97
98
  });
98
99
  try {
100
+ const resolvedTriggerUrl = options.triggerUrl
101
+ ? this.resolveTriggerUrl(options.triggerUrl, normalizedSiteId)
102
+ : undefined;
99
103
  // Resolve breakpoint target for this request.
100
104
  const cartridgeConfig = await this.resolveCartridgeConfig(options);
101
105
  if (!cartridgeConfig) {
@@ -117,7 +121,10 @@ export class ScriptDebuggerClient {
117
121
  // Set breakpoints for this specific request only.
118
122
  await this.setBreakpoints(cartridgeConfig);
119
123
  // Trigger request execution in storefront.
120
- const triggerPromise = this.triggerDefaultStart(siteId, locale);
124
+ const triggerPromise = this.triggerDefaultStart(normalizedSiteId, locale, resolvedTriggerUrl)
125
+ .catch(() => {
126
+ // Trigger request is best-effort while we poll debugger threads.
127
+ });
121
128
  // Poll for halted thread
122
129
  const thread = await this.waitForHaltedThread(timeout);
123
130
  if (!thread) {
@@ -138,9 +145,7 @@ export class ScriptDebuggerClient {
138
145
  await this.clearBreakpoints();
139
146
  await this.resumeThread(thread.id);
140
147
  // Let trigger settle in background (timeout is expected in some cases).
141
- triggerPromise.catch(() => {
142
- // Expected - request may timeout after thread resumes.
143
- });
148
+ void triggerPromise;
144
149
  return {
145
150
  success: true,
146
151
  result: evalResult,
@@ -259,6 +264,29 @@ export class ScriptDebuggerClient {
259
264
  this.cachedAuthHeader = `Basic ${Buffer.from(credentials).toString('base64')}`;
260
265
  return this.cachedAuthHeader;
261
266
  }
267
+ /**
268
+ * Build auth header for storefront trigger requests.
269
+ *
270
+ * Preference order:
271
+ * 1) Dedicated storefront credentials from dw.json
272
+ * 2) Primary basic auth credentials (username/password)
273
+ *
274
+ * OAuth credentials are intentionally not sent to storefront routes.
275
+ */
276
+ getStorefrontTriggerAuthHeader() {
277
+ const storefrontUsername = this.config.storefrontUsername?.trim();
278
+ const storefrontPassword = this.config.storefrontPassword?.trim();
279
+ if (storefrontUsername || storefrontPassword) {
280
+ if (!storefrontUsername || !storefrontPassword) {
281
+ throw new Error('Storefront credentials must include both storefrontUsername and storefrontPassword');
282
+ }
283
+ return `Basic ${Buffer.from(`${storefrontUsername}:${storefrontPassword}`).toString('base64')}`;
284
+ }
285
+ if (this.config.username && this.config.password) {
286
+ return `Basic ${Buffer.from(`${this.config.username}:${this.config.password}`).toString('base64')}`;
287
+ }
288
+ return undefined;
289
+ }
262
290
  /**
263
291
  * Get WebDAV client credentials
264
292
  */
@@ -452,13 +480,59 @@ export class ScriptDebuggerClient {
452
480
  const cleaned = trimmed.replace(/^\/+/, '').replace(/\/+$/, '');
453
481
  return cleaned.length > 0 ? cleaned : DEFAULT_LOCALE;
454
482
  }
483
+ /**
484
+ * Resolve a storefront trigger input into a fully-qualified URL for the configured instance.
485
+ *
486
+ * Supported forms:
487
+ * - Full URL (https://hostname/...)
488
+ * - Hostname-prefixed URL without scheme (hostname/...)
489
+ * - Absolute path (/on/demandware.store/... or /s/...)
490
+ * - Site-relative path (/womens/?lang=en_US -> /s/{siteId}/womens/?lang=en_US)
491
+ */
492
+ resolveTriggerUrl(triggerUrl, normalizedSiteId) {
493
+ const raw = triggerUrl.trim();
494
+ if (!raw) {
495
+ throw new Error('triggerUrl must not be empty');
496
+ }
497
+ const configuredHost = (this.config.hostname ?? '').toLowerCase();
498
+ const lowerRaw = raw.toLowerCase();
499
+ if (lowerRaw.startsWith('http://') || lowerRaw.startsWith('https://')) {
500
+ let parsed;
501
+ try {
502
+ parsed = new URL(raw);
503
+ }
504
+ catch {
505
+ throw new Error(`Invalid triggerUrl: ${raw}`);
506
+ }
507
+ if (parsed.hostname.toLowerCase() !== configuredHost) {
508
+ throw new Error(`triggerUrl hostname must match configured hostname (${this.config.hostname})`);
509
+ }
510
+ return parsed.toString();
511
+ }
512
+ if (lowerRaw.startsWith(configuredHost)) {
513
+ return `${this.protocol}://${raw}`;
514
+ }
515
+ const normalizedPath = raw.startsWith('/') ? raw : `/${raw}`;
516
+ if (normalizedPath.startsWith('/on/demandware.store/') || normalizedPath.startsWith('/s/')) {
517
+ return `${this.protocol}://${this.config.hostname}${normalizedPath}`;
518
+ }
519
+ const relativeSitePath = normalizedPath === '/' ? '/' : normalizedPath;
520
+ return `${this.protocol}://${this.config.hostname}/s/${normalizedSiteId}${relativeSitePath}`;
521
+ }
455
522
  /**
456
523
  * Trigger the Default-Start endpoint via HTTP
457
524
  */
458
- async triggerDefaultStart(siteId, locale) {
459
- // Normalize site ID in case it's passed as "Sites-{id}-Site"
525
+ async triggerDefaultStart(siteId, locale, triggerUrl) {
460
526
  const normalizedSiteId = this.normalizeSiteId(siteId);
461
527
  const normalizedLocale = this.normalizeLocale(locale);
528
+ if (triggerUrl) {
529
+ this.logger.debug('Triggering custom storefront URL', {
530
+ siteId: normalizedSiteId,
531
+ triggerUrl,
532
+ });
533
+ await this.triggerStorefrontUrl(triggerUrl);
534
+ return;
535
+ }
462
536
  // Some instances require the classic storefront URL format.
463
537
  // First try without locale (may redirect), then fall back to explicit locale.
464
538
  const siteSegment = `Sites-${normalizedSiteId}-Site`;
@@ -487,13 +561,18 @@ export class ScriptDebuggerClient {
487
561
  timeoutMs: TRIGGER_TIMEOUT_MS,
488
562
  timeoutMessage: `Storefront trigger timed out after ${TRIGGER_TIMEOUT_MS}ms`,
489
563
  });
564
+ const storefrontAuthHeader = this.getStorefrontTriggerAuthHeader();
565
+ const headers = {
566
+ Accept: 'text/html,application/xhtml+xml',
567
+ };
568
+ if (storefrontAuthHeader) {
569
+ headers.Authorization = storefrontAuthHeader;
570
+ }
490
571
  try {
491
572
  const response = await fetch(url, {
492
573
  method: 'GET',
493
574
  signal: timeoutController?.signal,
494
- headers: {
495
- Accept: 'text/html,application/xhtml+xml',
496
- },
575
+ headers,
497
576
  });
498
577
  if (!response.ok) {
499
578
  this.logger.debug('Storefront trigger non-OK response', { url, status: response.status });