sfcc-dev-mcp 1.0.15 → 1.0.19

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 (865) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +3 -1
  2. package/.github/ISSUE_TEMPLATE/documentation.yml +2 -2
  3. package/.github/ISSUE_TEMPLATE/question.yml +1 -1
  4. package/.github/PULL_REQUEST_TEMPLATE/documentation.md +1 -1
  5. package/.github/PULL_REQUEST_TEMPLATE/new_tool.md +1 -1
  6. package/.github/agents/official-docs-researcher.agent.md +56 -0
  7. package/.github/instructions/mcp-node-tests.instructions.md +12 -916
  8. package/.github/instructions/mcp-yml-tests.instructions.md +14 -742
  9. package/.github/pull_request_template.md +1 -1
  10. package/.github/skills/agent-authoring/SKILL.md +66 -0
  11. package/.github/skills/mcp-log-debugging/SKILL.md +69 -0
  12. package/.github/skills/mcp-programmatic-testing/SKILL.md +142 -0
  13. package/.github/skills/mcp-yaml-testing/SKILL.md +136 -0
  14. package/.github/skills/salesforce-developer-site-scraper/SKILL.md +102 -0
  15. package/.github/skills/salesforce-developer-site-scraper/scripts/scrape-to-markdown.js +205 -0
  16. package/.github/skills/salesforce-help-site-scraper/SKILL.md +84 -0
  17. package/.github/skills/salesforce-help-site-scraper/scripts/scrape-help-to-markdown.js +212 -0
  18. package/.github/skills/skill-authoring/SKILL.md +228 -0
  19. package/.github/skills/skill-authoring/references/PATTERNS.md +384 -0
  20. package/.github/workflows/ci.yml +3 -3
  21. package/.github/workflows/deploy-pages.yml +9 -19
  22. package/.github/workflows/publish.yml +5 -2
  23. package/.github/workflows/update-docs.yml +1 -1
  24. package/AGENTS.md +140 -286
  25. package/CONTRIBUTING.md +10 -22
  26. package/README.md +48 -16
  27. package/ai-instructions/{github-copilot/copilot-instructions.md → AGENTS.md} +99 -127
  28. package/ai-instructions/skills/sfcc-caching/SKILL.md +89 -0
  29. package/{dist/docs/best-practices/cartridge_creation.md → ai-instructions/skills/sfcc-cartridge-development/SKILL.md} +31 -7
  30. package/ai-instructions/skills/sfcc-forms-development/SKILL.md +261 -0
  31. package/ai-instructions/skills/sfcc-forms-development/references/ARCHITECTURE-SGJC-SFRA.md +143 -0
  32. package/ai-instructions/skills/sfcc-forms-development/references/FORM-XML-CHEATSHEET.md +127 -0
  33. package/ai-instructions/skills/sfcc-fraud-prevention/SKILL.md +95 -0
  34. package/ai-instructions/skills/sfcc-hooks-registration/SKILL.md +39 -0
  35. package/ai-instructions/skills/sfcc-isml-development/SKILL.md +370 -0
  36. package/ai-instructions/skills/sfcc-isml-development/references/REMOTE-INCLUDES.md +116 -0
  37. package/ai-instructions/skills/sfcc-isml-development/references/SFRA-LAYOUTS.md +50 -0
  38. package/ai-instructions/skills/sfcc-isml-development/references/SFRA-PAGES-CART-ACCOUNT-AUTH.md +45 -0
  39. package/ai-instructions/skills/sfcc-isml-development/references/SFRA-PAGES-CATALOG.md +85 -0
  40. package/ai-instructions/skills/sfcc-isml-development/references/SFRA-STRUCTURE-COMPONENTS.md +63 -0
  41. package/ai-instructions/skills/sfcc-isml-development/references/UTILITIES-EXPRESSIONS.md +159 -0
  42. package/ai-instructions/skills/sfcc-isml-development/references/sfra-base-templates-architecture.md +13 -0
  43. package/ai-instructions/skills/sfcc-job-development/SKILL.md +334 -0
  44. package/ai-instructions/skills/sfcc-job-development/references/CHUNK-ORIENTED.md +393 -0
  45. package/ai-instructions/skills/sfcc-job-development/references/STEPTYPES-JSON.md +271 -0
  46. package/ai-instructions/skills/sfcc-job-development/references/TASK-ORIENTED.md +257 -0
  47. package/ai-instructions/skills/sfcc-localization/SKILL.md +92 -0
  48. package/ai-instructions/skills/sfcc-localization/references/CONTROLLERS.md +63 -0
  49. package/ai-instructions/skills/sfcc-localization/references/FORMATTING.md +29 -0
  50. package/ai-instructions/skills/sfcc-localization/references/FORMS-LOCALIZATION.md +33 -0
  51. package/ai-instructions/skills/sfcc-localization/references/JAVASCRIPT-LOCALIZATION.md +41 -0
  52. package/ai-instructions/skills/sfcc-localization/references/LOCALE-SWITCHING.md +35 -0
  53. package/ai-instructions/skills/sfcc-localization/references/PATTERNS.md +740 -0
  54. package/ai-instructions/skills/sfcc-localization/references/PROPERTIES-ENCODING.md +25 -0
  55. package/ai-instructions/skills/sfcc-localization/references/RESOURCE-BUNDLES.md +67 -0
  56. package/ai-instructions/skills/sfcc-localization/references/STATIC-FILES.md +23 -0
  57. package/ai-instructions/skills/sfcc-localization/references/TESTING.md +21 -0
  58. package/{docs/best-practices/localserviceregistry.md → ai-instructions/skills/sfcc-localserviceregistry/SKILL.md} +65 -31
  59. package/ai-instructions/skills/sfcc-logging/SKILL.md +352 -0
  60. package/ai-instructions/skills/sfcc-logging/references/LOG-FILES.md +282 -0
  61. package/{docs/best-practices/ocapi_hooks.md → ai-instructions/skills/sfcc-ocapi-hooks/SKILL.md} +51 -16
  62. package/ai-instructions/skills/sfcc-ocapi-scapi-slas/SKILL.md +108 -0
  63. package/ai-instructions/skills/sfcc-page-designer/SKILL.md +353 -0
  64. package/ai-instructions/skills/sfcc-page-designer/references/ATTRIBUTE-TYPES.md +436 -0
  65. package/ai-instructions/skills/sfcc-page-designer/references/META-DEFINITIONS.md +322 -0
  66. package/{dist/docs/best-practices/performance.md → ai-instructions/skills/sfcc-performance/SKILL.md} +35 -3
  67. package/ai-instructions/skills/sfcc-platform-limits/SKILL.md +89 -0
  68. package/ai-instructions/skills/sfcc-scapi-custom-endpoints/SKILL.md +237 -0
  69. package/ai-instructions/skills/sfcc-scapi-custom-endpoints/references/AUTHENTICATION.md +214 -0
  70. package/ai-instructions/skills/sfcc-scapi-custom-endpoints/references/URL-MAPPING.md +253 -0
  71. package/{docs/best-practices/scapi_hooks.md → ai-instructions/skills/sfcc-scapi-hooks/SKILL.md} +44 -17
  72. package/ai-instructions/skills/sfcc-script-evaluation/SKILL.md +380 -0
  73. package/{docs/best-practices/security.md → ai-instructions/skills/sfcc-security/SKILL.md} +12 -3
  74. package/ai-instructions/skills/sfcc-sfra-client-side-js/SKILL.md +270 -0
  75. package/ai-instructions/skills/sfcc-sfra-client-side-js/references/AJAX-CSRF-VALIDATION.md +285 -0
  76. package/ai-instructions/skills/sfcc-sfra-client-side-js/references/BASE-MODULE-INDEX.md +206 -0
  77. package/ai-instructions/skills/sfcc-sfra-client-side-js/references/EXTENSION-PATTERNS.md +165 -0
  78. package/ai-instructions/skills/sfcc-sfra-client-side-js/references/PLUGIN-PATTERNS.md +185 -0
  79. package/ai-instructions/skills/sfcc-sfra-controllers/SKILL.md +347 -0
  80. package/ai-instructions/skills/sfcc-sfra-controllers/references/MIDDLEWARE-REFERENCE.md +257 -0
  81. package/ai-instructions/skills/sfcc-sfra-controllers/references/REMOTE-INCLUDES.md +193 -0
  82. package/{dist/docs/best-practices/sfra_controllers.md → ai-instructions/skills/sfcc-sfra-controllers/references/standard-sfra-controllers.md} +0 -670
  83. package/ai-instructions/skills/sfcc-sfra-models/SKILL.md +322 -0
  84. package/ai-instructions/skills/sfcc-sfra-models/references/MODEL-PATTERNS.md +530 -0
  85. package/ai-instructions/skills/sfcc-sfra-models/references/MODEL-STRUCTURE.md +234 -0
  86. package/ai-instructions/skills/sfcc-sfra-models/references/TESTING-SECURITY.md +417 -0
  87. package/{dist/docs/best-practices/sfra_scss.md → ai-instructions/skills/sfcc-sfra-scss/SKILL.md} +5 -0
  88. package/ai-instructions/skills/sfcc-webdav-workflows/SKILL.md +111 -0
  89. package/dist/ai-instructions/AGENTS.md +628 -0
  90. package/dist/ai-instructions/skills/sfcc-caching/SKILL.md +89 -0
  91. package/{docs/best-practices/cartridge_creation.md → dist/ai-instructions/skills/sfcc-cartridge-development/SKILL.md} +31 -7
  92. package/dist/ai-instructions/skills/sfcc-forms-development/SKILL.md +261 -0
  93. package/dist/ai-instructions/skills/sfcc-forms-development/references/ARCHITECTURE-SGJC-SFRA.md +143 -0
  94. package/dist/ai-instructions/skills/sfcc-forms-development/references/FORM-XML-CHEATSHEET.md +127 -0
  95. package/dist/ai-instructions/skills/sfcc-fraud-prevention/SKILL.md +95 -0
  96. package/dist/ai-instructions/skills/sfcc-hooks-registration/SKILL.md +39 -0
  97. package/dist/ai-instructions/skills/sfcc-isml-development/SKILL.md +370 -0
  98. package/dist/ai-instructions/skills/sfcc-isml-development/references/REMOTE-INCLUDES.md +116 -0
  99. package/dist/ai-instructions/skills/sfcc-isml-development/references/SFRA-LAYOUTS.md +50 -0
  100. package/dist/ai-instructions/skills/sfcc-isml-development/references/SFRA-PAGES-CART-ACCOUNT-AUTH.md +45 -0
  101. package/dist/ai-instructions/skills/sfcc-isml-development/references/SFRA-PAGES-CATALOG.md +85 -0
  102. package/dist/ai-instructions/skills/sfcc-isml-development/references/SFRA-STRUCTURE-COMPONENTS.md +63 -0
  103. package/dist/ai-instructions/skills/sfcc-isml-development/references/UTILITIES-EXPRESSIONS.md +159 -0
  104. package/dist/ai-instructions/skills/sfcc-isml-development/references/sfra-base-templates-architecture.md +13 -0
  105. package/dist/ai-instructions/skills/sfcc-job-development/SKILL.md +334 -0
  106. package/dist/ai-instructions/skills/sfcc-job-development/references/CHUNK-ORIENTED.md +393 -0
  107. package/dist/ai-instructions/skills/sfcc-job-development/references/STEPTYPES-JSON.md +271 -0
  108. package/dist/ai-instructions/skills/sfcc-job-development/references/TASK-ORIENTED.md +257 -0
  109. package/dist/ai-instructions/skills/sfcc-localization/SKILL.md +92 -0
  110. package/dist/ai-instructions/skills/sfcc-localization/references/CONTROLLERS.md +63 -0
  111. package/dist/ai-instructions/skills/sfcc-localization/references/FORMATTING.md +29 -0
  112. package/dist/ai-instructions/skills/sfcc-localization/references/FORMS-LOCALIZATION.md +33 -0
  113. package/dist/ai-instructions/skills/sfcc-localization/references/JAVASCRIPT-LOCALIZATION.md +41 -0
  114. package/dist/ai-instructions/skills/sfcc-localization/references/LOCALE-SWITCHING.md +35 -0
  115. package/dist/ai-instructions/skills/sfcc-localization/references/PATTERNS.md +740 -0
  116. package/dist/ai-instructions/skills/sfcc-localization/references/PROPERTIES-ENCODING.md +25 -0
  117. package/dist/ai-instructions/skills/sfcc-localization/references/RESOURCE-BUNDLES.md +67 -0
  118. package/dist/ai-instructions/skills/sfcc-localization/references/STATIC-FILES.md +23 -0
  119. package/dist/ai-instructions/skills/sfcc-localization/references/TESTING.md +21 -0
  120. package/dist/{docs/best-practices/localserviceregistry.md → ai-instructions/skills/sfcc-localserviceregistry/SKILL.md} +65 -31
  121. package/dist/ai-instructions/skills/sfcc-logging/SKILL.md +352 -0
  122. package/dist/ai-instructions/skills/sfcc-logging/references/LOG-FILES.md +282 -0
  123. package/dist/{docs/best-practices/ocapi_hooks.md → ai-instructions/skills/sfcc-ocapi-hooks/SKILL.md} +51 -16
  124. package/dist/ai-instructions/skills/sfcc-ocapi-scapi-slas/SKILL.md +108 -0
  125. package/dist/ai-instructions/skills/sfcc-page-designer/SKILL.md +353 -0
  126. package/dist/ai-instructions/skills/sfcc-page-designer/references/ATTRIBUTE-TYPES.md +436 -0
  127. package/dist/ai-instructions/skills/sfcc-page-designer/references/META-DEFINITIONS.md +322 -0
  128. package/{docs/best-practices/performance.md → dist/ai-instructions/skills/sfcc-performance/SKILL.md} +35 -3
  129. package/dist/ai-instructions/skills/sfcc-platform-limits/SKILL.md +89 -0
  130. package/dist/ai-instructions/skills/sfcc-scapi-custom-endpoints/SKILL.md +237 -0
  131. package/dist/ai-instructions/skills/sfcc-scapi-custom-endpoints/references/AUTHENTICATION.md +214 -0
  132. package/dist/ai-instructions/skills/sfcc-scapi-custom-endpoints/references/URL-MAPPING.md +253 -0
  133. package/dist/{docs/best-practices/scapi_hooks.md → ai-instructions/skills/sfcc-scapi-hooks/SKILL.md} +44 -17
  134. package/dist/ai-instructions/skills/sfcc-script-evaluation/SKILL.md +380 -0
  135. package/dist/{docs/best-practices/security.md → ai-instructions/skills/sfcc-security/SKILL.md} +12 -3
  136. package/dist/ai-instructions/skills/sfcc-sfra-client-side-js/SKILL.md +270 -0
  137. package/dist/ai-instructions/skills/sfcc-sfra-client-side-js/references/AJAX-CSRF-VALIDATION.md +285 -0
  138. package/dist/ai-instructions/skills/sfcc-sfra-client-side-js/references/BASE-MODULE-INDEX.md +206 -0
  139. package/dist/ai-instructions/skills/sfcc-sfra-client-side-js/references/EXTENSION-PATTERNS.md +165 -0
  140. package/dist/ai-instructions/skills/sfcc-sfra-client-side-js/references/PLUGIN-PATTERNS.md +185 -0
  141. package/dist/ai-instructions/skills/sfcc-sfra-controllers/SKILL.md +347 -0
  142. package/dist/ai-instructions/skills/sfcc-sfra-controllers/references/MIDDLEWARE-REFERENCE.md +257 -0
  143. package/dist/ai-instructions/skills/sfcc-sfra-controllers/references/REMOTE-INCLUDES.md +193 -0
  144. package/{docs/best-practices/sfra_controllers.md → dist/ai-instructions/skills/sfcc-sfra-controllers/references/standard-sfra-controllers.md} +0 -670
  145. package/dist/ai-instructions/skills/sfcc-sfra-models/SKILL.md +322 -0
  146. package/dist/ai-instructions/skills/sfcc-sfra-models/references/MODEL-PATTERNS.md +530 -0
  147. package/dist/ai-instructions/skills/sfcc-sfra-models/references/MODEL-STRUCTURE.md +234 -0
  148. package/dist/ai-instructions/skills/sfcc-sfra-models/references/TESTING-SECURITY.md +417 -0
  149. package/{docs/best-practices/sfra_scss.md → dist/ai-instructions/skills/sfcc-sfra-scss/SKILL.md} +5 -0
  150. package/dist/ai-instructions/skills/sfcc-webdav-workflows/SKILL.md +111 -0
  151. package/dist/clients/agent-instructions-client.d.ts +66 -0
  152. package/dist/clients/agent-instructions-client.d.ts.map +1 -0
  153. package/dist/clients/agent-instructions-client.js +277 -0
  154. package/dist/clients/agent-instructions-client.js.map +1 -0
  155. package/dist/clients/base/abstract-documentation-client.d.ts +146 -0
  156. package/dist/clients/base/abstract-documentation-client.d.ts.map +1 -0
  157. package/dist/clients/base/abstract-documentation-client.js +265 -0
  158. package/dist/clients/base/abstract-documentation-client.js.map +1 -0
  159. package/dist/clients/base/oauth-token.d.ts +18 -0
  160. package/dist/clients/base/oauth-token.d.ts.map +1 -1
  161. package/dist/clients/base/oauth-token.js +45 -2
  162. package/dist/clients/base/oauth-token.js.map +1 -1
  163. package/dist/clients/cartridge/cartridge-generation-client.d.ts +59 -0
  164. package/dist/clients/cartridge/cartridge-generation-client.d.ts.map +1 -0
  165. package/dist/clients/cartridge/cartridge-generation-client.js +224 -0
  166. package/dist/clients/cartridge/cartridge-generation-client.js.map +1 -0
  167. package/dist/clients/cartridge/cartridge-structure.d.ts +17 -0
  168. package/dist/clients/cartridge/cartridge-structure.d.ts.map +1 -0
  169. package/dist/clients/cartridge/cartridge-structure.js +33 -0
  170. package/dist/clients/cartridge/cartridge-structure.js.map +1 -0
  171. package/dist/clients/cartridge/cartridge-templates.d.ts +22 -0
  172. package/dist/clients/cartridge/cartridge-templates.d.ts.map +1 -0
  173. package/dist/clients/cartridge/cartridge-templates.js +225 -0
  174. package/dist/clients/cartridge/cartridge-templates.js.map +1 -0
  175. package/dist/clients/cartridge/index.d.ts +7 -0
  176. package/dist/clients/cartridge/index.d.ts.map +1 -0
  177. package/dist/clients/cartridge/index.js +7 -0
  178. package/dist/clients/cartridge/index.js.map +1 -0
  179. package/dist/clients/docs/documentation-scanner.d.ts +5 -2
  180. package/dist/clients/docs/documentation-scanner.d.ts.map +1 -1
  181. package/dist/clients/docs/documentation-scanner.js +38 -23
  182. package/dist/clients/docs/documentation-scanner.js.map +1 -1
  183. package/dist/clients/docs-client.d.ts +13 -4
  184. package/dist/clients/docs-client.d.ts.map +1 -1
  185. package/dist/clients/docs-client.js +44 -11
  186. package/dist/clients/docs-client.js.map +1 -1
  187. package/dist/clients/isml-client.d.ts +71 -0
  188. package/dist/clients/isml-client.d.ts.map +1 -0
  189. package/dist/clients/isml-client.js +252 -0
  190. package/dist/clients/isml-client.js.map +1 -0
  191. package/dist/clients/ocapi/code-versions-client.d.ts.map +1 -1
  192. package/dist/clients/ocapi/code-versions-client.js +6 -1
  193. package/dist/clients/ocapi/code-versions-client.js.map +1 -1
  194. package/dist/clients/ocapi-client.d.ts +9 -101
  195. package/dist/clients/ocapi-client.d.ts.map +1 -1
  196. package/dist/clients/ocapi-client.js +11 -93
  197. package/dist/clients/ocapi-client.js.map +1 -1
  198. package/dist/clients/script-debugger/index.d.ts +5 -0
  199. package/dist/clients/script-debugger/index.d.ts.map +1 -0
  200. package/dist/clients/script-debugger/index.js +5 -0
  201. package/dist/clients/script-debugger/index.js.map +1 -0
  202. package/dist/clients/script-debugger/script-debugger-client.d.ts +147 -0
  203. package/dist/clients/script-debugger/script-debugger-client.d.ts.map +1 -0
  204. package/dist/clients/script-debugger/script-debugger-client.js +591 -0
  205. package/dist/clients/script-debugger/script-debugger-client.js.map +1 -0
  206. package/dist/clients/sfra-client.d.ts +13 -62
  207. package/dist/clients/sfra-client.d.ts.map +1 -1
  208. package/dist/clients/sfra-client.js +105 -326
  209. package/dist/clients/sfra-client.js.map +1 -1
  210. package/dist/config/configuration-factory.d.ts +1 -1
  211. package/dist/config/configuration-factory.d.ts.map +1 -1
  212. package/dist/config/configuration-factory.js +5 -1
  213. package/dist/config/configuration-factory.js.map +1 -1
  214. package/dist/config/dw-json-loader.d.ts +7 -0
  215. package/dist/config/dw-json-loader.d.ts.map +1 -1
  216. package/dist/config/dw-json-loader.js +92 -15
  217. package/dist/config/dw-json-loader.js.map +1 -1
  218. package/dist/config/workspace-roots.d.ts +143 -0
  219. package/dist/config/workspace-roots.d.ts.map +1 -0
  220. package/dist/config/workspace-roots.js +448 -0
  221. package/dist/config/workspace-roots.js.map +1 -0
  222. package/dist/constants/index.d.ts +1 -0
  223. package/dist/constants/index.d.ts.map +1 -0
  224. package/dist/constants/index.js +3 -0
  225. package/dist/constants/index.js.map +1 -0
  226. package/dist/core/handlers/abstract-client-handler.d.ts +52 -0
  227. package/dist/core/handlers/abstract-client-handler.d.ts.map +1 -0
  228. package/dist/core/handlers/abstract-client-handler.js +51 -0
  229. package/dist/core/handlers/abstract-client-handler.js.map +1 -0
  230. package/dist/core/handlers/agent-instructions-handler.d.ts +17 -0
  231. package/dist/core/handlers/agent-instructions-handler.d.ts.map +1 -0
  232. package/dist/core/handlers/agent-instructions-handler.js +38 -0
  233. package/dist/core/handlers/agent-instructions-handler.js.map +1 -0
  234. package/dist/core/handlers/base-handler.d.ts +3 -68
  235. package/dist/core/handlers/base-handler.d.ts.map +1 -1
  236. package/dist/core/handlers/base-handler.js +11 -84
  237. package/dist/core/handlers/base-handler.js.map +1 -1
  238. package/dist/core/handlers/cartridge-handler.d.ts +10 -11
  239. package/dist/core/handlers/cartridge-handler.d.ts.map +1 -1
  240. package/dist/core/handlers/cartridge-handler.js +10 -28
  241. package/dist/core/handlers/cartridge-handler.js.map +1 -1
  242. package/dist/core/handlers/client-factory.d.ts +12 -2
  243. package/dist/core/handlers/client-factory.d.ts.map +1 -1
  244. package/dist/core/handlers/client-factory.js +28 -1
  245. package/dist/core/handlers/client-factory.js.map +1 -1
  246. package/dist/core/handlers/code-version-handler.d.ts +11 -11
  247. package/dist/core/handlers/code-version-handler.d.ts.map +1 -1
  248. package/dist/core/handlers/code-version-handler.js +13 -27
  249. package/dist/core/handlers/code-version-handler.js.map +1 -1
  250. package/dist/core/handlers/docs-handler.d.ts +6 -12
  251. package/dist/core/handlers/docs-handler.d.ts.map +1 -1
  252. package/dist/core/handlers/docs-handler.js +11 -36
  253. package/dist/core/handlers/docs-handler.js.map +1 -1
  254. package/dist/core/handlers/isml-handler.d.ts +11 -0
  255. package/dist/core/handlers/isml-handler.d.ts.map +1 -0
  256. package/dist/core/handlers/isml-handler.js +18 -0
  257. package/dist/core/handlers/isml-handler.js.map +1 -0
  258. package/dist/core/handlers/job-log-handler.d.ts +8 -7
  259. package/dist/core/handlers/job-log-handler.d.ts.map +1 -1
  260. package/dist/core/handlers/job-log-handler.js +14 -5
  261. package/dist/core/handlers/job-log-handler.js.map +1 -1
  262. package/dist/core/handlers/log-handler.d.ts +8 -7
  263. package/dist/core/handlers/log-handler.d.ts.map +1 -1
  264. package/dist/core/handlers/log-handler.js +14 -5
  265. package/dist/core/handlers/log-handler.js.map +1 -1
  266. package/dist/core/handlers/script-debugger-handler.d.ts +18 -0
  267. package/dist/core/handlers/script-debugger-handler.d.ts.map +1 -0
  268. package/dist/core/handlers/script-debugger-handler.js +31 -0
  269. package/dist/core/handlers/script-debugger-handler.js.map +1 -0
  270. package/dist/core/handlers/sfra-handler.d.ts +6 -12
  271. package/dist/core/handlers/sfra-handler.d.ts.map +1 -1
  272. package/dist/core/handlers/sfra-handler.js +11 -36
  273. package/dist/core/handlers/sfra-handler.js.map +1 -1
  274. package/dist/core/handlers/simple-client-handler.d.ts +41 -0
  275. package/dist/core/handlers/simple-client-handler.d.ts.map +1 -0
  276. package/dist/core/handlers/simple-client-handler.js +49 -0
  277. package/dist/core/handlers/simple-client-handler.js.map +1 -0
  278. package/dist/core/handlers/system-object-handler.d.ts +11 -11
  279. package/dist/core/handlers/system-object-handler.d.ts.map +1 -1
  280. package/dist/core/handlers/system-object-handler.js +13 -27
  281. package/dist/core/handlers/system-object-handler.js.map +1 -1
  282. package/dist/core/handlers/validation-helpers.d.ts +22 -24
  283. package/dist/core/handlers/validation-helpers.d.ts.map +1 -1
  284. package/dist/core/handlers/validation-helpers.js +89 -39
  285. package/dist/core/handlers/validation-helpers.js.map +1 -1
  286. package/dist/core/instruction-advisor.d.ts +28 -0
  287. package/dist/core/instruction-advisor.d.ts.map +1 -0
  288. package/dist/core/instruction-advisor.js +114 -0
  289. package/dist/core/instruction-advisor.js.map +1 -0
  290. package/dist/core/server.d.ts +25 -0
  291. package/dist/core/server.d.ts.map +1 -1
  292. package/dist/core/server.js +151 -11
  293. package/dist/core/server.js.map +1 -1
  294. package/dist/core/tool-definitions.d.ts +6 -854
  295. package/dist/core/tool-definitions.d.ts.map +1 -1
  296. package/dist/core/tool-definitions.js +8 -1064
  297. package/dist/core/tool-definitions.js.map +1 -1
  298. package/dist/core/tool-schemas/agent-instruction-tools.d.ts +77 -0
  299. package/dist/core/tool-schemas/agent-instruction-tools.d.ts.map +1 -0
  300. package/dist/core/tool-schemas/agent-instruction-tools.js +72 -0
  301. package/dist/core/tool-schemas/agent-instruction-tools.js.map +1 -0
  302. package/dist/core/tool-schemas/cartridge-tools.d.ts +27 -0
  303. package/dist/core/tool-schemas/cartridge-tools.d.ts.map +1 -0
  304. package/dist/core/tool-schemas/cartridge-tools.js +29 -0
  305. package/dist/core/tool-schemas/cartridge-tools.js.map +1 -0
  306. package/dist/core/tool-schemas/code-version-tools.d.ts +28 -0
  307. package/dist/core/tool-schemas/code-version-tools.d.ts.map +1 -0
  308. package/dist/core/tool-schemas/code-version-tools.js +28 -0
  309. package/dist/core/tool-schemas/code-version-tools.js.map +1 -0
  310. package/dist/core/tool-schemas/documentation-tools.d.ts +139 -0
  311. package/dist/core/tool-schemas/documentation-tools.d.ts.map +1 -0
  312. package/dist/core/tool-schemas/documentation-tools.js +104 -0
  313. package/dist/core/tool-schemas/documentation-tools.js.map +1 -0
  314. package/dist/core/tool-schemas/index.d.ts +17 -0
  315. package/dist/core/tool-schemas/index.d.ts.map +1 -0
  316. package/dist/core/tool-schemas/index.js +19 -0
  317. package/dist/core/tool-schemas/index.js.map +1 -0
  318. package/dist/core/tool-schemas/isml-tools.d.ts +98 -0
  319. package/dist/core/tool-schemas/isml-tools.d.ts.map +1 -0
  320. package/dist/core/tool-schemas/isml-tools.js +89 -0
  321. package/dist/core/tool-schemas/isml-tools.js.map +1 -0
  322. package/dist/core/tool-schemas/log-tools.d.ts +221 -0
  323. package/dist/core/tool-schemas/log-tools.d.ts.map +1 -0
  324. package/dist/core/tool-schemas/log-tools.js +180 -0
  325. package/dist/core/tool-schemas/log-tools.js.map +1 -0
  326. package/dist/core/tool-schemas/script-debugger-tools.d.ts +44 -0
  327. package/dist/core/tool-schemas/script-debugger-tools.d.ts.map +1 -0
  328. package/dist/core/tool-schemas/script-debugger-tools.js +83 -0
  329. package/dist/core/tool-schemas/script-debugger-tools.js.map +1 -0
  330. package/dist/core/tool-schemas/sfra-tools.d.ts +63 -0
  331. package/dist/core/tool-schemas/sfra-tools.d.ts.map +1 -0
  332. package/dist/core/tool-schemas/sfra-tools.js +65 -0
  333. package/dist/core/tool-schemas/sfra-tools.js.map +1 -0
  334. package/dist/core/tool-schemas/shared-schemas.d.ts +350 -0
  335. package/dist/core/tool-schemas/shared-schemas.d.ts.map +1 -0
  336. package/dist/core/tool-schemas/shared-schemas.js +153 -0
  337. package/dist/core/tool-schemas/shared-schemas.js.map +1 -0
  338. package/dist/core/tool-schemas/system-object-tools.d.ts +511 -0
  339. package/dist/core/tool-schemas/system-object-tools.d.ts.map +1 -0
  340. package/dist/core/tool-schemas/system-object-tools.js +126 -0
  341. package/dist/core/tool-schemas/system-object-tools.js.map +1 -0
  342. package/dist/docs/dw_net/HTTPClient.md +46 -2
  343. package/dist/docs/dw_net/HTTPClientLoggingConfig.md +296 -0
  344. package/dist/docs/dw_order/Basket.md +7 -7
  345. package/dist/docs/dw_order/BasketMgr.md +22 -6
  346. package/dist/docs/dw_order.hooks/BasketMergeHooks.md +42 -0
  347. package/dist/docs/dw_svc/ServiceCallback.md +2 -2
  348. package/dist/docs/isml/isactivedatacontext.md +382 -0
  349. package/dist/docs/isml/isactivedatahead.md +566 -0
  350. package/dist/docs/isml/isanalyticsoff.md +537 -0
  351. package/dist/docs/isml/isapplepay.md +667 -0
  352. package/dist/docs/isml/isbreak.md +687 -0
  353. package/dist/docs/isml/isbuynow.md +682 -0
  354. package/dist/docs/isml/iscache.md +802 -0
  355. package/dist/docs/isml/iscomment.md +794 -0
  356. package/dist/docs/isml/iscomponent.md +797 -0
  357. package/dist/docs/isml/iscontent.md +594 -0
  358. package/dist/docs/isml/iscontinue.md +563 -0
  359. package/dist/docs/isml/iscookie.md +798 -0
  360. package/dist/docs/isml/isdecorate.md +818 -0
  361. package/dist/docs/isml/isif.md +737 -0
  362. package/dist/docs/isml/isinclude.md +874 -0
  363. package/dist/docs/isml/isloop.md +377 -0
  364. package/dist/docs/isml/ismodule.md +844 -0
  365. package/dist/docs/isml/isnext.md +672 -0
  366. package/dist/docs/isml/isobject.md +760 -0
  367. package/dist/docs/isml/ispayment.md +577 -0
  368. package/dist/docs/isml/ispaymentmessages.md +664 -0
  369. package/dist/docs/isml/isprint.md +875 -0
  370. package/dist/docs/isml/isredirect.md +716 -0
  371. package/dist/docs/isml/isremove.md +725 -0
  372. package/dist/docs/isml/isreplace.md +783 -0
  373. package/dist/docs/isml/isscript.md +859 -0
  374. package/dist/docs/isml/isselect.md +908 -0
  375. package/dist/docs/isml/isset.md +585 -0
  376. package/dist/docs/isml/isslot.md +824 -0
  377. package/dist/docs/isml/isstatus.md +711 -0
  378. package/dist/main.d.ts +16 -0
  379. package/dist/main.d.ts.map +1 -1
  380. package/dist/main.js +60 -28
  381. package/dist/main.js.map +1 -1
  382. package/dist/services/index.d.ts +4 -2
  383. package/dist/services/index.d.ts.map +1 -1
  384. package/dist/services/index.js +2 -2
  385. package/dist/services/index.js.map +1 -1
  386. package/dist/tool-configs/agent-instructions-tool-config.d.ts +6 -0
  387. package/dist/tool-configs/agent-instructions-tool-config.d.ts.map +1 -0
  388. package/dist/tool-configs/agent-instructions-tool-config.js +74 -0
  389. package/dist/tool-configs/agent-instructions-tool-config.js.map +1 -0
  390. package/dist/tool-configs/code-version-tool-config.d.ts.map +1 -1
  391. package/dist/tool-configs/code-version-tool-config.js +0 -5
  392. package/dist/tool-configs/code-version-tool-config.js.map +1 -1
  393. package/dist/tool-configs/docs-tool-config.d.ts.map +1 -1
  394. package/dist/tool-configs/docs-tool-config.js +0 -7
  395. package/dist/tool-configs/docs-tool-config.js.map +1 -1
  396. package/dist/tool-configs/isml-tool-config.d.ts +11 -0
  397. package/dist/tool-configs/isml-tool-config.d.ts.map +1 -0
  398. package/dist/tool-configs/isml-tool-config.js +77 -0
  399. package/dist/tool-configs/isml-tool-config.js.map +1 -0
  400. package/dist/tool-configs/job-log-tool-config.d.ts +1 -2
  401. package/dist/tool-configs/job-log-tool-config.d.ts.map +1 -1
  402. package/dist/tool-configs/job-log-tool-config.js +11 -15
  403. package/dist/tool-configs/job-log-tool-config.js.map +1 -1
  404. package/dist/tool-configs/log-tool-config.d.ts +1 -2
  405. package/dist/tool-configs/log-tool-config.d.ts.map +1 -1
  406. package/dist/tool-configs/log-tool-config.js +35 -51
  407. package/dist/tool-configs/log-tool-config.js.map +1 -1
  408. package/dist/tool-configs/script-debugger-tool-config.d.ts +11 -0
  409. package/dist/tool-configs/script-debugger-tool-config.d.ts.map +1 -0
  410. package/dist/tool-configs/script-debugger-tool-config.js +35 -0
  411. package/dist/tool-configs/script-debugger-tool-config.js.map +1 -0
  412. package/dist/tool-configs/sfra-tool-config.d.ts.map +1 -1
  413. package/dist/tool-configs/sfra-tool-config.js +0 -11
  414. package/dist/tool-configs/sfra-tool-config.js.map +1 -1
  415. package/dist/tool-configs/system-object-tool-config.d.ts.map +1 -1
  416. package/dist/tool-configs/system-object-tool-config.js +0 -5
  417. package/dist/tool-configs/system-object-tool-config.js.map +1 -1
  418. package/dist/types/types.d.ts +2 -0
  419. package/dist/types/types.d.ts.map +1 -1
  420. package/dist/utils/cache.d.ts +12 -10
  421. package/dist/utils/cache.d.ts.map +1 -1
  422. package/dist/utils/cache.js +47 -47
  423. package/dist/utils/cache.js.map +1 -1
  424. package/dist/utils/category-utils.d.ts +31 -0
  425. package/dist/utils/category-utils.d.ts.map +1 -0
  426. package/dist/utils/category-utils.js +45 -0
  427. package/dist/utils/category-utils.js.map +1 -0
  428. package/dist/utils/log-tool-constants.d.ts +16 -13
  429. package/dist/utils/log-tool-constants.d.ts.map +1 -1
  430. package/dist/utils/log-tool-constants.js +10 -11
  431. package/dist/utils/log-tool-constants.js.map +1 -1
  432. package/dist/utils/logger.d.ts +11 -0
  433. package/dist/utils/logger.d.ts.map +1 -1
  434. package/dist/utils/logger.js +35 -1
  435. package/dist/utils/logger.js.map +1 -1
  436. package/dist/utils/markdown-utils.d.ts +60 -0
  437. package/dist/utils/markdown-utils.d.ts.map +1 -0
  438. package/dist/utils/markdown-utils.js +206 -0
  439. package/dist/utils/markdown-utils.js.map +1 -0
  440. package/dist/utils/path-resolver.d.ts +12 -4
  441. package/dist/utils/path-resolver.d.ts.map +1 -1
  442. package/dist/utils/path-resolver.js +22 -8
  443. package/dist/utils/path-resolver.js.map +1 -1
  444. package/dist/utils/path-validation.d.ts +40 -0
  445. package/dist/utils/path-validation.d.ts.map +1 -0
  446. package/dist/utils/path-validation.js +84 -0
  447. package/dist/utils/path-validation.js.map +1 -0
  448. package/docs/dw_net/HTTPClient.md +46 -2
  449. package/docs/dw_net/HTTPClientLoggingConfig.md +296 -0
  450. package/docs/dw_order/Basket.md +7 -7
  451. package/docs/dw_order/BasketMgr.md +22 -6
  452. package/docs/dw_order.hooks/BasketMergeHooks.md +42 -0
  453. package/docs/dw_svc/ServiceCallback.md +2 -2
  454. package/docs/isml/isactivedatacontext.md +382 -0
  455. package/docs/isml/isactivedatahead.md +566 -0
  456. package/docs/isml/isanalyticsoff.md +537 -0
  457. package/docs/isml/isapplepay.md +667 -0
  458. package/docs/isml/isbreak.md +687 -0
  459. package/docs/isml/isbuynow.md +682 -0
  460. package/docs/isml/iscache.md +802 -0
  461. package/docs/isml/iscomment.md +794 -0
  462. package/docs/isml/iscomponent.md +797 -0
  463. package/docs/isml/iscontent.md +594 -0
  464. package/docs/isml/iscontinue.md +563 -0
  465. package/docs/isml/iscookie.md +798 -0
  466. package/docs/isml/isdecorate.md +818 -0
  467. package/docs/isml/isif.md +737 -0
  468. package/docs/isml/isinclude.md +874 -0
  469. package/docs/isml/isloop.md +377 -0
  470. package/docs/isml/ismodule.md +844 -0
  471. package/docs/isml/isnext.md +672 -0
  472. package/docs/isml/isobject.md +760 -0
  473. package/docs/isml/ispayment.md +577 -0
  474. package/docs/isml/ispaymentmessages.md +664 -0
  475. package/docs/isml/isprint.md +875 -0
  476. package/docs/isml/isredirect.md +716 -0
  477. package/docs/isml/isremove.md +725 -0
  478. package/docs/isml/isreplace.md +783 -0
  479. package/docs/isml/isscript.md +859 -0
  480. package/docs/isml/isselect.md +908 -0
  481. package/docs/isml/isset.md +585 -0
  482. package/docs/isml/isslot.md +824 -0
  483. package/docs/isml/isstatus.md +711 -0
  484. package/docs-site-v2/.vitepress/config.mts +190 -0
  485. package/docs-site-v2/.vitepress/theme/components/AssistantTabs.vue +96 -0
  486. package/docs-site-v2/.vitepress/theme/components/Callout.vue +10 -0
  487. package/docs-site-v2/.vitepress/theme/components/Collapsible.vue +14 -0
  488. package/docs-site-v2/.vitepress/theme/components/DwJsonBuilder.vue +82 -0
  489. package/docs-site-v2/.vitepress/theme/components/HomeSections.vue +552 -0
  490. package/docs-site-v2/.vitepress/theme/components/InstructionFilesTabs.vue +87 -0
  491. package/docs-site-v2/.vitepress/theme/components/ModeTabs.vue +70 -0
  492. package/docs-site-v2/.vitepress/theme/components/NewcomerCTA.vue +14 -0
  493. package/docs-site-v2/.vitepress/theme/components/QuickStartCards.vue +20 -0
  494. package/docs-site-v2/.vitepress/theme/components/QuickStartHero.vue +20 -0
  495. package/docs-site-v2/.vitepress/theme/components/SkillsList.vue +48 -0
  496. package/docs-site-v2/.vitepress/theme/components/ToolExplorer.vue +85 -0
  497. package/docs-site-v2/.vitepress/theme/custom.css +1373 -0
  498. package/docs-site-v2/.vitepress/theme/index.ts +39 -0
  499. package/docs-site-v2/data/skills.ts +147 -0
  500. package/docs-site-v2/data/tools.ts +490 -0
  501. package/docs-site-v2/development/index.md +151 -0
  502. package/docs-site-v2/examples/index.md +333 -0
  503. package/docs-site-v2/features/index.md +144 -0
  504. package/docs-site-v2/guide/ai-interfaces.md +58 -0
  505. package/docs-site-v2/guide/configuration.md +208 -0
  506. package/docs-site-v2/guide/index.md +50 -0
  507. package/docs-site-v2/index.md +32 -0
  508. package/docs-site-v2/package-lock.json +2511 -0
  509. package/docs-site-v2/package.json +15 -0
  510. package/docs-site-v2/public/android-chrome-192x192.png +0 -0
  511. package/docs-site-v2/public/android-chrome-512x512.png +0 -0
  512. package/docs-site-v2/public/apple-touch-icon.png +0 -0
  513. package/docs-site-v2/public/favicon-16x16.png +0 -0
  514. package/docs-site-v2/public/favicon-32x32.png +0 -0
  515. package/docs-site-v2/public/favicon.ico +0 -0
  516. package/docs-site-v2/public/index.css +4174 -0
  517. package/docs-site-v2/public/llms.txt +44 -0
  518. package/docs-site-v2/public/logo-dark.svg +8 -0
  519. package/docs-site-v2/public/logo.svg +8 -0
  520. package/{docs-site → docs-site-v2}/public/robots.txt +1 -6
  521. package/{docs-site → docs-site-v2}/public/site.webmanifest +1 -1
  522. package/{docs-site → docs-site-v2}/public/sitemap.xml +33 -12
  523. package/docs-site-v2/script-debugger/index.md +105 -0
  524. package/docs-site-v2/scripts/generate-llms.js +71 -0
  525. package/docs-site-v2/scripts/generate-sitemap.js +97 -0
  526. package/docs-site-v2/security/index.md +115 -0
  527. package/docs-site-v2/skills/index.md +40 -0
  528. package/docs-site-v2/tools/index.md +36 -0
  529. package/docs-site-v2/troubleshooting/index.md +204 -0
  530. package/eslint.config.js +3 -1
  531. package/memories/repo/docs-site-v2-build.json +11 -0
  532. package/package.json +18 -14
  533. package/scripts/validate-server-json.js +68 -0
  534. package/server.json +4 -6
  535. package/src/clients/agent-instructions-client.ts +370 -0
  536. package/src/clients/base/abstract-documentation-client.ts +405 -0
  537. package/src/clients/base/oauth-token.ts +52 -2
  538. package/src/clients/cartridge/cartridge-generation-client.ts +302 -0
  539. package/src/clients/cartridge/cartridge-structure.ts +37 -0
  540. package/src/clients/cartridge/cartridge-templates.ts +246 -0
  541. package/src/clients/cartridge/index.ts +6 -0
  542. package/src/clients/docs/documentation-scanner.ts +44 -28
  543. package/src/clients/docs-client.ts +54 -14
  544. package/src/clients/isml-client.ts +353 -0
  545. package/src/clients/ocapi/code-versions-client.ts +7 -1
  546. package/src/clients/ocapi-client.ts +11 -166
  547. package/src/clients/script-debugger/index.ts +5 -0
  548. package/src/clients/script-debugger/script-debugger-client.ts +754 -0
  549. package/src/clients/sfra-client.ts +134 -397
  550. package/src/config/configuration-factory.ts +6 -1
  551. package/src/config/dw-json-loader.ts +96 -15
  552. package/src/config/workspace-roots.ts +540 -0
  553. package/src/constants/index.ts +1 -0
  554. package/src/core/handlers/abstract-client-handler.ts +85 -0
  555. package/src/core/handlers/agent-instructions-handler.ts +48 -0
  556. package/src/core/handlers/base-handler.ts +17 -127
  557. package/src/core/handlers/cartridge-handler.ts +13 -33
  558. package/src/core/handlers/client-factory.ts +32 -2
  559. package/src/core/handlers/code-version-handler.ts +17 -32
  560. package/src/core/handlers/docs-handler.ts +12 -44
  561. package/src/core/handlers/isml-handler.ts +19 -0
  562. package/src/core/handlers/job-log-handler.ts +19 -8
  563. package/src/core/handlers/log-handler.ts +19 -8
  564. package/src/core/handlers/script-debugger-handler.ts +46 -0
  565. package/src/core/handlers/sfra-handler.ts +12 -44
  566. package/src/core/handlers/simple-client-handler.ts +78 -0
  567. package/src/core/handlers/system-object-handler.ts +17 -32
  568. package/src/core/handlers/validation-helpers.ts +87 -47
  569. package/src/core/instruction-advisor.ts +122 -0
  570. package/src/core/server.ts +178 -13
  571. package/src/core/tool-definitions.ts +25 -1071
  572. package/src/core/tool-schemas/agent-instruction-tools.ts +72 -0
  573. package/src/core/tool-schemas/cartridge-tools.ts +29 -0
  574. package/src/core/tool-schemas/code-version-tools.ts +28 -0
  575. package/src/core/tool-schemas/documentation-tools.ts +104 -0
  576. package/src/core/tool-schemas/index.ts +27 -0
  577. package/src/core/tool-schemas/isml-tools.ts +89 -0
  578. package/src/core/tool-schemas/log-tools.ts +196 -0
  579. package/src/core/tool-schemas/script-debugger-tools.ts +83 -0
  580. package/src/core/tool-schemas/sfra-tools.ts +65 -0
  581. package/src/core/tool-schemas/shared-schemas.ts +158 -0
  582. package/src/core/tool-schemas/system-object-tools.ts +127 -0
  583. package/src/main.ts +63 -30
  584. package/src/services/index.ts +4 -10
  585. package/src/tool-configs/agent-instructions-tool-config.ts +83 -0
  586. package/src/tool-configs/cartridge-tool-config.ts +1 -1
  587. package/src/tool-configs/code-version-tool-config.ts +0 -5
  588. package/src/tool-configs/docs-tool-config.ts +0 -7
  589. package/src/tool-configs/isml-tool-config.ts +87 -0
  590. package/src/tool-configs/job-log-tool-config.ts +18 -17
  591. package/src/tool-configs/log-tool-config.ts +49 -64
  592. package/src/tool-configs/script-debugger-tool-config.ts +69 -0
  593. package/src/tool-configs/sfra-tool-config.ts +0 -11
  594. package/src/tool-configs/system-object-tool-config.ts +0 -5
  595. package/src/types/types.ts +2 -0
  596. package/src/utils/cache.ts +49 -54
  597. package/src/utils/category-utils.ts +70 -0
  598. package/src/utils/log-tool-constants.ts +25 -17
  599. package/src/utils/logger.ts +38 -1
  600. package/src/utils/markdown-utils.ts +280 -0
  601. package/src/utils/path-resolver.ts +25 -9
  602. package/src/utils/path-validation.ts +113 -0
  603. package/tests/base-handler.test.ts +1 -1
  604. package/tests/cache.test.ts +2 -2
  605. package/tests/cartridge-handler.test.ts +4 -4
  606. package/tests/client-factory.test.ts +1 -1
  607. package/tests/code-version-handler.test.ts +3 -3
  608. package/tests/docs-handler.test.ts +2 -2
  609. package/tests/documentation-scanner.test.ts +4 -4
  610. package/tests/isml-client.test.ts +463 -0
  611. package/tests/isml-handler.test.ts +375 -0
  612. package/tests/job-log-handler.test.ts +1 -1
  613. package/tests/log-handler.test.ts +8 -8
  614. package/tests/log-validation.test.ts +149 -0
  615. package/tests/mcp/README.md +22 -18
  616. package/tests/mcp/node/activate-code-version-advanced.full-mode.programmatic.test.js +30 -12
  617. package/tests/mcp/node/evaluate-script.full-mode.programmatic.test.js +387 -0
  618. package/tests/mcp/node/generate-cartridge-structure.docs-only.programmatic.test.js +14 -8
  619. package/tests/mcp/node/get-isml-categories.programmatic.test.js +278 -0
  620. package/tests/mcp/node/get-isml-element.programmatic.test.js +278 -0
  621. package/tests/mcp/node/get-isml-elements-by-category.programmatic.test.js +363 -0
  622. package/tests/mcp/node/get-sfra-categories.docs-only.programmatic.test.js +24 -24
  623. package/tests/mcp/node/get-sfra-document.programmatic.test.js +4 -2
  624. package/tests/mcp/node/list-isml-elements.programmatic.test.js +311 -0
  625. package/tests/mcp/node/list-sfcc-classes.docs-only.programmatic.test.js +2 -33
  626. package/tests/mcp/node/search-isml-elements.programmatic.test.js +325 -0
  627. package/tests/mcp/node/search-sfcc-classes.docs-only.programmatic.test.js +5 -9
  628. package/tests/mcp/node/search-sfcc-methods.docs-only.programmatic.test.js +7 -9
  629. package/tests/mcp/node/tools.docs-only.programmatic.test.js +42 -65
  630. package/tests/mcp/node/tools.full-mode.programmatic.test.js +7 -8
  631. package/tests/mcp/yaml/activate-code-version.full-mode.test.mcp.yml +2 -2
  632. package/tests/mcp/yaml/evaluate-script.full-mode.test.mcp.yml +281 -0
  633. package/tests/mcp/yaml/get-isml-categories.docs-only.test.mcp.yml +330 -0
  634. package/tests/mcp/yaml/get-isml-element.docs-only.test.mcp.yml +294 -0
  635. package/tests/mcp/yaml/get-isml-elements-by-category.docs-only.test.mcp.yml +334 -0
  636. package/tests/mcp/yaml/get-sfcc-class-info.docs-only.test.mcp.yml +2 -2
  637. package/tests/mcp/yaml/get-sfra-categories.docs-only.test.mcp.yml +13 -13
  638. package/tests/mcp/yaml/get-sfra-categories.full-mode.test.mcp.yml +13 -13
  639. package/tests/mcp/yaml/get-system-object-definitions.docs-only.test.mcp.yml +1 -16
  640. package/tests/mcp/yaml/list-isml-elements.docs-only.test.mcp.yml +212 -0
  641. package/tests/mcp/yaml/search-isml-elements.docs-only.test.mcp.yml +312 -0
  642. package/tests/mcp/yaml/search-sfcc-classes.docs-only.test.mcp.yml +1 -1
  643. package/tests/mcp/yaml/search-sfcc-classes.full-mode.test.mcp.yml +1 -1
  644. package/tests/mcp/yaml/search-site-preferences.docs-only.test.mcp.yml +1 -1
  645. package/tests/mcp/yaml/tools.docs-only.test.mcp.yml +3 -57
  646. package/tests/mcp/yaml/tools.full-mode.test.mcp.yml +3 -3
  647. package/tests/oauth-token.test.ts +107 -12
  648. package/tests/ocapi-client.test.ts +53 -106
  649. package/tests/script-debugger-client.test.ts +430 -0
  650. package/tests/servers/sfcc-mock-server/src/app.js +15 -0
  651. package/tests/servers/sfcc-mock-server/src/routes/cartridge-webdav.js +258 -0
  652. package/tests/servers/sfcc-mock-server/src/routes/ocapi/debugger-handler.js +396 -0
  653. package/tests/servers/sfcc-mock-server/src/routes/ocapi.js +5 -0
  654. package/tests/servers/sfcc-mock-server/src/routes/storefront.js +86 -0
  655. package/tests/servers/sfcc-mock-server/src/routes/webdav.js +6 -4
  656. package/tests/validation-helpers.test.ts +0 -31
  657. package/tests/workspace-roots.test.ts +227 -0
  658. package/ai-instructions/claude-desktop/claude_custom_instructions.md +0 -321
  659. package/ai-instructions/cursor/.cursor/rules/debugging-workflows.mdc +0 -171
  660. package/ai-instructions/cursor/.cursor/rules/hooks-development.mdc +0 -168
  661. package/ai-instructions/cursor/.cursor/rules/isml-templates.mdc +0 -209
  662. package/ai-instructions/cursor/.cursor/rules/job-framework.mdc +0 -379
  663. package/ai-instructions/cursor/.cursor/rules/performance-optimization.mdc +0 -215
  664. package/ai-instructions/cursor/.cursor/rules/scapi-endpoints.mdc +0 -98
  665. package/ai-instructions/cursor/.cursor/rules/security-patterns.mdc +0 -375
  666. package/ai-instructions/cursor/.cursor/rules/sfcc-development.mdc +0 -144
  667. package/ai-instructions/cursor/.cursor/rules/sfra-controllers.mdc +0 -376
  668. package/ai-instructions/cursor/.cursor/rules/sfra-models.mdc +0 -412
  669. package/ai-instructions/cursor/.cursor/rules/system-objects.mdc +0 -383
  670. package/ai-instructions/cursor/.cursor/rules/testing-patterns.mdc +0 -418
  671. package/dist/clients/best-practices-client.d.ts +0 -57
  672. package/dist/clients/best-practices-client.d.ts.map +0 -1
  673. package/dist/clients/best-practices-client.js +0 -288
  674. package/dist/clients/best-practices-client.js.map +0 -1
  675. package/dist/clients/cartridge-generation-client.d.ts +0 -57
  676. package/dist/clients/cartridge-generation-client.d.ts.map +0 -1
  677. package/dist/clients/cartridge-generation-client.js +0 -384
  678. package/dist/clients/cartridge-generation-client.js.map +0 -1
  679. package/dist/clients/logs/index.d.ts +0 -13
  680. package/dist/clients/logs/index.d.ts.map +0 -1
  681. package/dist/clients/logs/index.js +0 -15
  682. package/dist/clients/logs/index.js.map +0 -1
  683. package/dist/clients/logs/log-analyzer.d.ts +0 -55
  684. package/dist/clients/logs/log-analyzer.d.ts.map +0 -1
  685. package/dist/clients/logs/log-analyzer.js +0 -228
  686. package/dist/clients/logs/log-analyzer.js.map +0 -1
  687. package/dist/clients/logs/log-client.d.ts +0 -87
  688. package/dist/clients/logs/log-client.d.ts.map +0 -1
  689. package/dist/clients/logs/log-client.js +0 -418
  690. package/dist/clients/logs/log-client.js.map +0 -1
  691. package/dist/clients/logs/log-constants.d.ts +0 -37
  692. package/dist/clients/logs/log-constants.d.ts.map +0 -1
  693. package/dist/clients/logs/log-constants.js +0 -37
  694. package/dist/clients/logs/log-constants.js.map +0 -1
  695. package/dist/clients/logs/log-file-discovery.d.ts +0 -62
  696. package/dist/clients/logs/log-file-discovery.d.ts.map +0 -1
  697. package/dist/clients/logs/log-file-discovery.js +0 -238
  698. package/dist/clients/logs/log-file-discovery.js.map +0 -1
  699. package/dist/clients/logs/log-file-reader.d.ts +0 -53
  700. package/dist/clients/logs/log-file-reader.d.ts.map +0 -1
  701. package/dist/clients/logs/log-file-reader.js +0 -194
  702. package/dist/clients/logs/log-file-reader.js.map +0 -1
  703. package/dist/clients/logs/log-formatter.d.ts +0 -90
  704. package/dist/clients/logs/log-formatter.d.ts.map +0 -1
  705. package/dist/clients/logs/log-formatter.js +0 -189
  706. package/dist/clients/logs/log-formatter.js.map +0 -1
  707. package/dist/clients/logs/log-processor.d.ts +0 -91
  708. package/dist/clients/logs/log-processor.d.ts.map +0 -1
  709. package/dist/clients/logs/log-processor.js +0 -328
  710. package/dist/clients/logs/log-processor.js.map +0 -1
  711. package/dist/clients/logs/log-types.d.ts +0 -69
  712. package/dist/clients/logs/log-types.d.ts.map +0 -1
  713. package/dist/clients/logs/log-types.js +0 -5
  714. package/dist/clients/logs/log-types.js.map +0 -1
  715. package/dist/clients/logs/webdav-client-manager.d.ts +0 -28
  716. package/dist/clients/logs/webdav-client-manager.d.ts.map +0 -1
  717. package/dist/clients/logs/webdav-client-manager.js +0 -77
  718. package/dist/clients/logs/webdav-client-manager.js.map +0 -1
  719. package/dist/core/handlers/abstract-log-tool-handler.d.ts +0 -35
  720. package/dist/core/handlers/abstract-log-tool-handler.d.ts.map +0 -1
  721. package/dist/core/handlers/abstract-log-tool-handler.js +0 -46
  722. package/dist/core/handlers/abstract-log-tool-handler.js.map +0 -1
  723. package/dist/core/handlers/best-practices-handler.d.ts +0 -17
  724. package/dist/core/handlers/best-practices-handler.d.ts.map +0 -1
  725. package/dist/core/handlers/best-practices-handler.js +0 -43
  726. package/dist/core/handlers/best-practices-handler.js.map +0 -1
  727. package/dist/core/handlers/job-log-tool-config.d.ts +0 -8
  728. package/dist/core/handlers/job-log-tool-config.d.ts.map +0 -1
  729. package/dist/core/handlers/job-log-tool-config.js +0 -76
  730. package/dist/core/handlers/job-log-tool-config.js.map +0 -1
  731. package/dist/core/handlers/log-tool-config.d.ts +0 -8
  732. package/dist/core/handlers/log-tool-config.d.ts.map +0 -1
  733. package/dist/core/handlers/log-tool-config.js +0 -73
  734. package/dist/core/handlers/log-tool-config.js.map +0 -1
  735. package/dist/docs/best-practices/isml_templates.md +0 -1933
  736. package/dist/docs/best-practices/job_framework.md +0 -1173
  737. package/dist/docs/best-practices/scapi_custom_endpoint.md +0 -963
  738. package/dist/docs/best-practices/sfra_client_side_js.md +0 -736
  739. package/dist/docs/best-practices/sfra_models.md +0 -1142
  740. package/dist/tool-configs/best-practices-tool-config.d.ts +0 -11
  741. package/dist/tool-configs/best-practices-tool-config.d.ts.map +0 -1
  742. package/dist/tool-configs/best-practices-tool-config.js +0 -59
  743. package/dist/tool-configs/best-practices-tool-config.js.map +0 -1
  744. package/dist/utils/job-log-tool-config.d.ts +0 -8
  745. package/dist/utils/job-log-tool-config.d.ts.map +0 -1
  746. package/dist/utils/job-log-tool-config.js +0 -76
  747. package/dist/utils/job-log-tool-config.js.map +0 -1
  748. package/dist/utils/job-log-utils.d.ts +0 -34
  749. package/dist/utils/job-log-utils.d.ts.map +0 -1
  750. package/dist/utils/job-log-utils.js +0 -60
  751. package/dist/utils/job-log-utils.js.map +0 -1
  752. package/dist/utils/log-cache.d.ts +0 -53
  753. package/dist/utils/log-cache.d.ts.map +0 -1
  754. package/dist/utils/log-cache.js +0 -114
  755. package/dist/utils/log-cache.js.map +0 -1
  756. package/dist/utils/log-tool-config.d.ts +0 -8
  757. package/dist/utils/log-tool-config.d.ts.map +0 -1
  758. package/dist/utils/log-tool-config.js +0 -73
  759. package/dist/utils/log-tool-config.js.map +0 -1
  760. package/dist/utils/log-tool-utils.d.ts +0 -39
  761. package/dist/utils/log-tool-utils.d.ts.map +0 -1
  762. package/dist/utils/log-tool-utils.js +0 -94
  763. package/dist/utils/log-tool-utils.js.map +0 -1
  764. package/docs/best-practices/isml_templates.md +0 -1933
  765. package/docs/best-practices/job_framework.md +0 -1173
  766. package/docs/best-practices/scapi_custom_endpoint.md +0 -963
  767. package/docs/best-practices/sfra_client_side_js.md +0 -736
  768. package/docs/best-practices/sfra_models.md +0 -1142
  769. package/docs-site/App.tsx +0 -103
  770. package/docs-site/README.md +0 -113
  771. package/docs-site/components/Badge.tsx +0 -38
  772. package/docs-site/components/BreadcrumbSchema.tsx +0 -34
  773. package/docs-site/components/CodeBlock.tsx +0 -132
  774. package/docs-site/components/Collapsible.tsx +0 -40
  775. package/docs-site/components/ConfigBuilder.tsx +0 -118
  776. package/docs-site/components/ConfigHero.tsx +0 -19
  777. package/docs-site/components/ConfigModeTabs.tsx +0 -42
  778. package/docs-site/components/Layout.tsx +0 -174
  779. package/docs-site/components/LightCodeContainer.tsx +0 -44
  780. package/docs-site/components/NewcomerCTA.tsx +0 -57
  781. package/docs-site/components/NextStepsStrip.tsx +0 -23
  782. package/docs-site/components/OnThisPage.tsx +0 -91
  783. package/docs-site/components/SEO.tsx +0 -79
  784. package/docs-site/components/Search.tsx +0 -207
  785. package/docs-site/components/Sidebar.tsx +0 -96
  786. package/docs-site/components/StructuredData.tsx +0 -72
  787. package/docs-site/components/ToolCard.tsx +0 -84
  788. package/docs-site/components/ToolFilters.tsx +0 -39
  789. package/docs-site/components/Typography.tsx +0 -30
  790. package/docs-site/components/VersionBadge.tsx +0 -18
  791. package/docs-site/components/icons.tsx +0 -37
  792. package/docs-site/constants.tsx +0 -34
  793. package/docs-site/index.html +0 -62
  794. package/docs-site/main.tsx +0 -16
  795. package/docs-site/metadata.json +0 -5
  796. package/docs-site/package-lock.json +0 -3966
  797. package/docs-site/package.json +0 -35
  798. package/docs-site/pages/AIInterfacesPage.tsx +0 -610
  799. package/docs-site/pages/ConfigurationPage.tsx +0 -315
  800. package/docs-site/pages/DevelopmentPage.tsx +0 -607
  801. package/docs-site/pages/ExamplesPage.tsx +0 -558
  802. package/docs-site/pages/FeaturesPage.tsx +0 -353
  803. package/docs-site/pages/HomePage.tsx +0 -1046
  804. package/docs-site/pages/SecurityPage.tsx +0 -372
  805. package/docs-site/pages/ToolsPage.tsx +0 -205
  806. package/docs-site/pages/TroubleshootingPage.tsx +0 -590
  807. package/docs-site/postcss.config.js +0 -6
  808. package/docs-site/public/.well-known/security.txt +0 -6
  809. package/docs-site/public/android-chrome-192x192.png +0 -0
  810. package/docs-site/public/android-chrome-512x512.png +0 -0
  811. package/docs-site/public/apple-touch-icon.png +0 -0
  812. package/docs-site/public/favicon-16x16.png +0 -0
  813. package/docs-site/public/favicon-32x32.png +0 -0
  814. package/docs-site/public/favicon.ico +0 -0
  815. package/docs-site/public/llms.txt +0 -47
  816. package/docs-site/scripts/generate-search-index.js +0 -323
  817. package/docs-site/scripts/generate-sitemap.js +0 -156
  818. package/docs-site/scripts/search-dev.js +0 -112
  819. package/docs-site/src/styles/input.css +0 -248
  820. package/docs-site/src/styles/prism-theme.css +0 -124
  821. package/docs-site/tailwind.config.js +0 -70
  822. package/docs-site/tsconfig.json +0 -29
  823. package/docs-site/types.ts +0 -16
  824. package/docs-site/utils/search.ts +0 -132
  825. package/docs-site/utils/toolsData.ts +0 -116
  826. package/docs-site/vite.config.ts +0 -63
  827. package/src/clients/best-practices-client.ts +0 -332
  828. package/src/clients/cartridge-generation-client.ts +0 -507
  829. package/src/clients/logs/index.ts +0 -18
  830. package/src/clients/logs/log-analyzer.ts +0 -289
  831. package/src/clients/logs/log-client.ts +0 -540
  832. package/src/clients/logs/log-constants.ts +0 -53
  833. package/src/clients/logs/log-file-discovery.ts +0 -299
  834. package/src/clients/logs/log-file-reader.ts +0 -227
  835. package/src/clients/logs/log-formatter.ts +0 -258
  836. package/src/clients/logs/log-processor.ts +0 -402
  837. package/src/clients/logs/log-types.ts +0 -80
  838. package/src/clients/logs/webdav-client-manager.ts +0 -93
  839. package/src/core/handlers/abstract-log-tool-handler.ts +0 -64
  840. package/src/core/handlers/best-practices-handler.ts +0 -55
  841. package/src/core/handlers/job-log-tool-config.ts +0 -89
  842. package/src/core/handlers/log-tool-config.ts +0 -98
  843. package/src/tool-configs/best-practices-tool-config.ts +0 -68
  844. package/src/utils/job-log-tool-config.ts +0 -89
  845. package/src/utils/job-log-utils.ts +0 -78
  846. package/src/utils/log-cache.ts +0 -134
  847. package/src/utils/log-tool-config.ts +0 -98
  848. package/src/utils/log-tool-utils.ts +0 -122
  849. package/tests/best-practices-handler.test.ts +0 -236
  850. package/tests/job-log-utils.test.ts +0 -182
  851. package/tests/mcp/node/get-available-best-practice-guides.docs-only.programmatic.test.js +0 -516
  852. package/tests/mcp/node/get-best-practice-guide.docs-only.programmatic.test.js +0 -733
  853. package/tests/mcp/node/get-hook-reference.docs-only.programmatic.test.js +0 -185
  854. package/tests/mcp/node/search-best-practices.docs-only.programmatic.test.js +0 -836
  855. package/tests/mcp/yaml/get-available-best-practice-guides.docs-only.test.mcp.yml +0 -885
  856. package/tests/mcp/yaml/get-available-best-practice-guides.full-mode.test.mcp.yml +0 -885
  857. package/tests/mcp/yaml/get-best-practice-guide.docs-only.test.mcp.yml +0 -462
  858. package/tests/mcp/yaml/get-best-practice-guide.full-mode.test.mcp.yml +0 -462
  859. package/tests/mcp/yaml/get-hook-reference.docs-only.test.mcp.yml +0 -321
  860. package/tests/mcp/yaml/get-hook-reference.full-mode.test.mcp.yml +0 -321
  861. package/tests/mcp/yaml/search-best-practices.docs-only.test.mcp.yml +0 -655
  862. package/tests/mcp/yaml/search-best-practices.full-mode.test.mcp.yml +0 -655
  863. /package/{docs-site → docs-site-v2}/public/404.html +0 -0
  864. /package/{docs-site → docs-site-v2}/public/explain-product-pricing-methods-no-mcp.png +0 -0
  865. /package/{docs-site → docs-site-v2}/public/explain-product-pricing-methods.png +0 -0
@@ -1,963 +0,0 @@
1
- # Salesforce B2C Commerce: Custom SCAPI Endpoint Best Practices
2
-
3
- This guide provides a concise overview of best practices and examples for creating custom Salesforce Commerce API (SCAPI) endpoints in B2C Commerce Cloud.
4
-
5
- **IMPORTANT**: Before implementing custom SCAPI endpoints, consult the **Performance and Stability Best Practices** guide from this MCP server. Pay special attention to the external system integration guidelines, timeout requirements, and caching strategies for optimal endpoint performance.
6
-
7
- ## 1. Authentication Methodologies for Custom SCAPI Endpoints
8
-
9
- Custom SCAPI endpoints leverage the Shopper Login and API Access Service (SLAS) for authentication and authorization. Understanding SLAS authentication flows is critical for secure endpoint implementation.
10
-
11
- ### 1.1 Client Architecture Decision: Public vs. Private
12
-
13
- The most critical architectural decision is determining your client type, which dictates the entire authentication flow:
14
-
15
- #### Private Clients
16
- - **Capability**: Can securely store a `client_secret` on a server-side component
17
- - **Use Cases**: Backend-for-Frontend (BFF), full-stack web applications, server-to-server integrations
18
- - **Security Model**: Uses `client_secret` in Basic Authorization header for client authentication
19
- - **OAuth Grant Types**:
20
- - `client_credentials` (guest users, system operations)
21
- - `authorization_code` (registered user authentication)
22
-
23
- #### Public Clients
24
- - **Capability**: Cannot securely store secrets (operates in untrusted environments)
25
- - **Use Cases**: PWA Kit storefronts, Single-Page Applications (SPAs), native mobile apps
26
- - **Security Model**: Uses Proof Key for Code Exchange (PKCE) for dynamic security
27
- - **OAuth Grant Types**:
28
- - `authorization_code_pkce` (all authentication scenarios)
29
-
30
- ### 1.2 Security Best Practices
31
-
32
- #### Scope-Based Authorization in Custom Endpoints
33
-
34
- Always implement fine-grained authorization checks in your endpoint scripts:
35
-
36
- ```javascript
37
- // In your custom endpoint script
38
- exports.getLoyaltyInfo = function () {
39
- var customerId = request.getHttpParameterMap().get('c_customer_id').getStringValue();
40
-
41
- // CRITICAL: Verify the authenticated user can access this customer's data
42
- if (request.user && request.user.profile) {
43
- var authenticatedCustomerId = request.user.profile.customerNo;
44
-
45
- // Prevent privilege escalation
46
- if (authenticatedCustomerId !== customerId) {
47
- RESTResponseMgr.createError(403, "insufficient-privileges",
48
- "Access Denied", "Cannot access another customer's data").render();
49
- return;
50
- }
51
- }
52
-
53
- // Continue with business logic...
54
- };
55
- ```
56
-
57
- ### 1.3 Client Configuration and Scope Management
58
-
59
- #### SLAS Client Configuration
60
-
61
- Configure clients using the SLAS Admin API or UI:
62
-
63
- ```javascript
64
- // Example API call to create/update a SLAS client
65
- const clientConfig = {
66
- "clientId": "your-client-id",
67
- "name": "My Custom API Client",
68
- "isPrivateClient": true, // or false for public clients
69
- "secret": "secure-client-secret", // Only for private clients
70
- "channels": ["your-site-id"],
71
- "scopes": [
72
- "sfcc.shopper-baskets-orders.rw",
73
- "sfcc.shopper-myaccount.rw",
74
- "sfcc.shopper-products",
75
- "c_read_loyalty", // Your custom scope
76
- "c_write_loyalty"
77
- ],
78
- "redirectUri": [
79
- "https://your-app.com/callback"
80
- ]
81
- };
82
- ```
83
-
84
- #### Custom Object Scopes
85
-
86
- For accessing custom objects via SCAPI, configure both the object and scope:
87
-
88
- 1. **Define Custom Object** in Business Manager: `Administration > Site Development > Custom Object Types`
89
- 2. **Add Scope** to SLAS client: `sfcc.shopper-custom-objects.{object-type-id}`
90
-
91
- ```yaml
92
- # In your schema.yaml
93
- security:
94
- - ShopperToken: [sfcc.shopper-custom-objects.StoreReview]
95
- ```
96
-
97
- ### 1.4 Authentication Flow Examples & Testing
98
-
99
- #### Private Client: Guest Token Flow (Client Credentials)
100
-
101
- For server-side applications using private clients:
102
-
103
- ```bash
104
- # Get Guest Token
105
- wget --post-data="grant_type=client_credentials" \
106
- --header="Authorization: Basic $(echo -n 'your-private-client-id:your-client-secret' | base64)" \
107
- --header="Content-Type: application/x-www-form-urlencoded" \
108
- -O token_response.json \
109
- "https://your-shortcode.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/f_ecom_your_org/oauth2/token"
110
-
111
- # Extract Token and Test API Call
112
- TOKEN=$(cat token_response.json | grep -o '"access_token":"[^"]*' | cut -d'"' -f4)
113
- wget --header="Authorization: Bearer $TOKEN" \
114
- -O categories.json \
115
- "https://your-shortcode.api.commercecloud.salesforce.com/product/shopper-products/v1/organizations/f_ecom_your_org/categories/root?siteId=your-site-id"
116
- ```
117
-
118
- #### Public Client: PKCE Authentication Flow
119
-
120
- For browser-based applications using PKCE:
121
-
122
- ```bash
123
- # Generate PKCE Challenge
124
- VERIFIER=$(openssl rand -base64 96 | tr -d '\n' | tr '/+' '_-' | tr -d '=')
125
- CHALLENGE=$(echo -n $VERIFIER | openssl dgst -binary -sha256 | openssl base64 -A | tr '/' '_' | tr '+' '-' | tr -d '=')
126
-
127
- # Get Authorization Code (returns redirect with usid and code)
128
- wget --server-response --spider \
129
- "https://your-shortcode.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/f_ecom_your_org/oauth2/authorize?redirect_uri=http://localhost:3000/callback&response_type=code&hint=guest&client_id=your-public-client-id&code_challenge=$CHALLENGE" \
130
- 2>&1 | grep -i location
131
-
132
- # Exchange Code for Token (extract usid and code from Location header)
133
- wget --post-data="client_id=your-public-client-id&channel_id=your-site-id&code_verifier=$VERIFIER&usid=your-usid&code=your-code&grant_type=authorization_code_pkce&redirect_uri=http://localhost:3000/callback" \
134
- --header="Content-Type: application/x-www-form-urlencoded" \
135
- -O pkce_token_response.json \
136
- "https://your-shortcode.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/f_ecom_your_org/oauth2/token"
137
- ```
138
-
139
- ### 1.5 Error Handling and Troubleshooting
140
-
141
- #### Common Authentication Errors
142
-
143
- | Error Code | Cause | Solution |
144
- |------------|-------|----------|
145
- | 401 Unauthorized | Invalid or expired token | Refresh token or re-authenticate |
146
- | 403 Forbidden | Valid token, missing scope | Check client scope configuration |
147
- | 400 Bad Request | Invalid PKCE parameters | Verify code_verifier/code_challenge |
148
- | 404 Not Found | Incorrect endpoint URL | Verify API registration and URL structure |
149
-
150
- #### Token Validation in Scripts
151
-
152
- ```javascript
153
- // Validate token and extract user information
154
- function validateAndExtractUser() {
155
- if (!request.user) {
156
- RESTResponseMgr.createError(401, "unauthorized",
157
- "Authentication Required", "Valid token required").render();
158
- return null;
159
- }
160
-
161
- // For registered users
162
- if (request.user.profile && request.user.profile.customerNo) {
163
- return {
164
- type: 'registered',
165
- customerId: request.user.profile.customerNo,
166
- email: request.user.profile.email
167
- };
168
- }
169
-
170
- // For guest users
171
- return {
172
- type: 'guest',
173
- customerId: request.user.ID // Guest customer ID
174
- };
175
- }
176
- ```
177
-
178
- #### Accessing Customer Context in Headless APIs
179
-
180
- Even though SCAPI endpoints use JWT-based authentication without traditional sessions, you can still access the authenticated customer:
181
-
182
- ```javascript
183
- // Access the current customer (works for both registered and guest users)
184
- exports.getCustomerInfo = function () {
185
- var session = request.getSession();
186
- var customer = session.getCustomer();
187
-
188
- if (!customer) {
189
- RESTResponseMgr.createError(401, "unauthorized",
190
- "No Customer", "No authenticated customer found").render();
191
- return;
192
- }
193
-
194
- var customerData = {
195
- isRegistered: customer.isRegistered(),
196
- isAuthenticated: customer.isAuthenticated()
197
- };
198
-
199
- // For registered customers, access profile information
200
- if (customer.isRegistered() && customer.getProfile()) {
201
- var profile = customer.getProfile();
202
- customerData.customerId = profile.getCustomerNo();
203
- customerData.email = profile.getEmail();
204
- customerData.firstName = profile.getFirstName();
205
- customerData.lastName = profile.getLastName();
206
- } else {
207
- // For guest customers
208
- customerData.customerId = customer.getID();
209
- customerData.isGuest = true;
210
- }
211
-
212
- RESTResponseMgr.createSuccess(customerData).render();
213
- };
214
-
215
- exports.getCustomerInfo.public = true;
216
- ```
217
-
218
- ## 2. URL Structure and Endpoint Mapping
219
-
220
- Understanding how your OpenAPI schema translates to actual SCAPI endpoint URLs is crucial for both development and client integration.
221
-
222
- ### 2.1 SCAPI URL Structure
223
-
224
- All custom SCAPI endpoints follow this standardized URL pattern:
225
-
226
- ```
227
- https://{shortcode}.api.commercecloud.salesforce.com/custom/{api-name}/v{major-version}/organizations/{organization-id}{path}?{query-parameters}
228
- ```
229
-
230
- **URL Components:**
231
- - **`{shortcode}`**: Your SFCC instance shortcode (e.g., `zzrf-001`, `my-company-dev`)
232
- - **`{api-name}`**: The directory name under `cartridge/rest-apis/` in your cartridge
233
- - **`v{major-version}`**: Automatically derived from `info.version` in your `schema.yaml` (e.g., "1.0.0" → "v1", "2.3.1" → "v2")
234
- - **`{organization-id}`**: Your SFCC organization ID (typically starts with `f_ecom_`)
235
- - **`{path}`**: The path defined in your OpenAPI schema
236
- - **`{query-parameters}`**: Query string parameters from your schema
237
-
238
- ### 2.2 Schema-to-URL Mapping Examples
239
-
240
- #### Example 1: Simple Query Parameters
241
-
242
- **OpenAPI Schema Definition:**
243
- ```yaml
244
- # File: int_product_api/cartridge/rest-apis/product-info/schema.yaml
245
- openapi: 3.0.0
246
- info:
247
- title: Product Information API
248
- version: "1.0.0"
249
- paths:
250
- /products/{sku}:
251
- get:
252
- summary: Retrieves basic product information by SKU
253
- operationId: getProductInfo
254
- parameters:
255
- - name: siteId
256
- in: query
257
- required: true
258
- schema:
259
- type: string
260
- minLength: 1
261
- - name: sku
262
- in: path
263
- required: true
264
- schema:
265
- type: string
266
- minLength: 1
267
- ```
268
-
269
- **Resulting Endpoint URL:**
270
- ```
271
- https://{{shortcode}}.api.commercecloud.salesforce.com/custom/product-info/v1/organizations/{{organizationId}}/products/682875540326M?siteId=RefArchGlobal
272
- ```
273
-
274
- **Complete Example:**
275
- ```
276
- https://zzrf-001.api.commercecloud.salesforce.com/custom/product-info/v1/organizations/f_ecom_zzrf_001/products/682875540326M?siteId=RefArchGlobal
277
- ```
278
-
279
- #### Example 2: Complex Query Parameters with Custom Attributes
280
-
281
- **OpenAPI Schema Definition:**
282
- ```yaml
283
- # File: int_pricing_api/cartridge/rest-apis/pricing-api/schema.yaml
284
- openapi: 3.0.0
285
- info:
286
- title: Advanced Pricing API
287
- version: "1.2.0" # Results in v1 URL
288
- paths:
289
- /product-pricing/{productId}:
290
- get:
291
- summary: Retrieves comprehensive pricing information for a product SKU
292
- description: |
293
- Returns detailed pricing information for a given product including:
294
- - Base price and promotional prices
295
- - Available coupon-based promotions (without requiring coupon codes)
296
- - Price ranges for master products
297
- - Quantity-based pricing tiers
298
- operationId: getProductPricing
299
- parameters:
300
- - name: siteId
301
- in: query
302
- required: true
303
- description: Site identifier for the pricing context
304
- schema:
305
- type: string
306
- minLength: 1
307
- - name: productId
308
- in: path
309
- required: true
310
- description: Product ID or SKU to get pricing for
311
- schema:
312
- type: string
313
- minLength: 1
314
- - name: c_quantity
315
- in: query
316
- required: false
317
- description: Quantity for tiered pricing calculation (defaults to 1)
318
- schema:
319
- type: number
320
- minimum: 1
321
- default: 1
322
- - name: c_currency
323
- in: query
324
- required: false
325
- description: Currency code for price display (defaults to session currency)
326
- schema:
327
- type: string
328
- pattern: '^[A-Z]{3}$'
329
- - name: c_include_upcoming_promotions
330
- in: query
331
- required: false
332
- description: Include upcoming promotions within next 24 hours
333
- schema:
334
- type: boolean
335
- default: false
336
- ```
337
-
338
- **Resulting Endpoint URL:**
339
- ```
340
- https://{{shortcode}}.api.commercecloud.salesforce.com/custom/pricing-api/v1/organizations/{{organizationId}}/product-pricing/product-123?siteId=your-site-id&c_quantity=2&c_include_upcoming_promotions=true
341
- ```
342
-
343
- **Complete Example:**
344
- ```
345
- https://your-shortcode.api.commercecloud.salesforce.com/custom/pricing-api/v1/organizations/your-org-id/product-pricing/product-123?siteId=your-site-id&c_quantity=2&c_include_upcoming_promotions=true
346
- ```
347
-
348
- #### Example 3: Nested Resource Paths
349
-
350
- **OpenAPI Schema Definition:**
351
- ```yaml
352
- # File: int_customer_api/cartridge/rest-apis/customer-management/schema.yaml
353
- openapi: 3.0.0
354
- info:
355
- title: Customer Management API
356
- version: "2.0.0" # Results in v2 URL
357
- paths:
358
- /customers/{customerId}/orders/{orderId}/tracking:
359
- get:
360
- summary: Get order tracking information
361
- operationId: getOrderTracking
362
- parameters:
363
- - name: siteId
364
- in: query
365
- required: true
366
- schema:
367
- type: string
368
- - name: customerId
369
- in: path
370
- required: true
371
- schema:
372
- type: string
373
- - name: orderId
374
- in: path
375
- required: true
376
- schema:
377
- type: string
378
- - name: c_include_delivery_details
379
- in: query
380
- required: false
381
- schema:
382
- type: boolean
383
- default: false
384
- ```
385
-
386
- **Resulting Endpoint URL:**
387
- ```
388
- https://{{shortcode}}.api.commercecloud.salesforce.com/custom/customer-management/v2/organizations/{{organizationId}}/customers/12345/orders/ORD-001234/tracking?siteId=SiteGenesis&c_include_delivery_details=true
389
- ```
390
-
391
- ### 2.3 Parameter Access in Scripts
392
-
393
- Understanding how to access different parameter types in your script implementation:
394
-
395
- ```javascript
396
- 'use strict';
397
-
398
- var RESTResponseMgr = require('dw/system/RESTResponseMgr');
399
-
400
- exports.getProductPricing = function () {
401
- // Path parameters: use getSCAPIPathParameters()
402
- var productId = request.getSCAPIPathParameters().get('productId');
403
-
404
- // Query parameters: use getHttpParameterMap()
405
- var siteId = request.getHttpParameterMap().get('siteId').getStringValue();
406
- var quantity = request.getHttpParameterMap().get('c_quantity').getIntValue() || 1;
407
- var currency = request.getHttpParameterMap().get('c_currency').getStringValue();
408
- var includeUpcoming = request.getHttpParameterMap().get('c_include_upcoming_promotions').getBooleanValue();
409
-
410
- // Parameter validation
411
- if (!productId) {
412
- RESTResponseMgr.createError(400, "missing-product-id",
413
- "Missing Product ID", "Product ID is required in the path").render();
414
- return;
415
- }
416
-
417
- // Business logic implementation...
418
- var pricingData = {
419
- productId: productId,
420
- basePrice: 29.99,
421
- salePrice: 24.99,
422
- currency: currency || "USD",
423
- quantity: quantity,
424
- upcomingPromotions: includeUpcoming ? [] : undefined
425
- };
426
-
427
- RESTResponseMgr.createSuccess(pricingData).render();
428
- };
429
-
430
- exports.getProductPricing.public = true;
431
- ```
432
-
433
- ### 2.4 Version Management in URLs
434
-
435
- The version segment in your URL is automatically determined by the major version number in your OpenAPI schema:
436
-
437
- | Schema Version | URL Version | Example URL |
438
- |----------------|-------------|-------------|
439
- | "1.0.0" | v1 | `/custom/my-api/v1/organizations/...` |
440
- | "1.2.5" | v1 | `/custom/my-api/v1/organizations/...` |
441
- | "2.0.0" | v2 | `/custom/my-api/v2/organizations/...` |
442
- | "2.1.3" | v2 | `/custom/my-api/v2/organizations/...` |
443
- | "3.0.0-beta" | v3 | `/custom/my-api/v3/organizations/...` |
444
-
445
- **Best Practice**: Use semantic versioning in your schema and introduce breaking changes only in new major versions to maintain backward compatibility.
446
-
447
- ### 2.5 Testing Your URL Mappings
448
-
449
- #### Using Postman/cURL
450
-
451
- ```bash
452
- # Test the product pricing endpoint
453
- curl -X GET \
454
- 'https://your-shortcode.api.commercecloud.salesforce.com/custom/pricing-api/v1/organizations/your-org-id/product-pricing/product-123?siteId=your-site-id&c_quantity=2&c_include_upcoming_promotions=true' \
455
- -H 'Authorization: Bearer YOUR_SLAS_TOKEN' \
456
- -H 'Content-Type: application/json'
457
- ```
458
-
459
- ### 2.6 Common Issues and Solutions
460
-
461
- | Issue | Symptom | Solution |
462
- |-------|---------|----------|
463
- | 404 Not Found | Endpoint not accessible | Check cartridge registration, API directory name, and schema syntax |
464
- | Version mismatch | Wrong version in URL | Verify `info.version` in schema.yaml matches expected URL |
465
- | Parameter not found | Script can't access parameters | Ensure parameter names match schema exactly, use correct access method |
466
- | Invalid path structure | URL doesn't match expected pattern | Verify path definition in schema matches your intended URL structure |
467
-
468
- ### 2.7 Documentation for Client Developers
469
-
470
- When documenting your custom endpoints for client developers, always provide:
471
-
472
- 1. **Complete URL Examples**: Show the full URL with real values
473
- 2. **Parameter Descriptions**: Explain what each parameter does and its format requirements
474
- 3. **Authentication Requirements**: Specify required scopes and token types
475
- 4. **Response Examples**: Include sample JSON responses
476
- 5. **Error Scenarios**: Document common error codes and their meanings
477
-
478
- **Example Documentation:**
479
-
480
- ```markdown
481
- ## Get Product Pricing
482
-
483
- Retrieves comprehensive pricing information for a product.
484
-
485
- ### Endpoint
486
- `GET /custom/pricing-api/v1/organizations/{organizationId}/product-pricing/{productId}`
487
-
488
- ### Full URL Example
489
- ```
490
- https://your-shortcode.api.commercecloud.salesforce.com/custom/pricing-api/v1/organizations/f_ecom_your_org/product-pricing/ABC123?siteId=RefArchGlobal&c_quantity=2
491
- ```
492
-
493
- ### Parameters
494
- - `productId` (path, required): Product SKU or ID
495
- - `siteId` (query, required): Site identifier
496
- - `c_quantity` (query, optional): Quantity for tiered pricing (default: 1)
497
- - `c_currency` (query, optional): Currency code (default: session currency)
498
-
499
- ### Authentication
500
- Requires SLAS Shopper Token with scope: `c_read_pricing`
501
- ```
502
-
503
- This URL structure understanding is essential for both endpoint development and client integration, ensuring your custom SCAPI endpoints are accessible and properly documented.
504
-
505
- ## 3. Securing Endpoints
506
-
507
- Endpoints must be associated with a security scheme in the API contract. SCAPI supports two primary security schemes for custom endpoints:
508
-
509
- - **ShopperToken**: For Shopper APIs and storefront use cases. Use Shopper Login and API Access to obtain tokens.
510
- - **AmOAuth2**: For SCAPI Admin APIs to be used with backoffice apps. Use Account Manager to obtain tokens.
511
-
512
- Association is either per operation or global, with the operation scheme taking precedence. The schemes are the same as those used for non-custom B2C Commerce APIs (SCAPI).
513
-
514
- The scheme must set exactly one custom scope.
515
-
516
- ### 3.1 Security Scheme Configuration
517
-
518
- Schemes used in the contract must be defined in the components section, for example:
519
-
520
- ```yaml
521
- components:
522
- securitySchemes:
523
- ShopperToken: {}
524
- AmOAuth2:
525
- type: oauth2
526
-
527
- # 👇 A global scheme applies to all operations in this file.
528
- security:
529
- - AmOAuth2: ["c_loyalty_rw"]
530
-
531
- paths:
532
- /customer:
533
- get:
534
- operationId: getLoyaltyInfo
535
- parameters:
536
- - in: query
537
- name: siteId
538
- required: true
539
- schema:
540
- type: string
541
- minLength: 1
542
- responses:
543
- 200:
544
- description: OK
545
- # 👇 An operation scheme applies only to this operation and takes precedence over the global scheme.
546
- security:
547
- - ShopperToken: ["c_loyalty"]
548
- ```
549
-
550
- ### 3.2 Custom Scope Requirements
551
-
552
- Custom scopes must meet the following requirements:
553
-
554
- - The name must begin with `c_`.
555
- - The name must not contain characters other than alphanumeric, period, hyphen and underscore.
556
- - The name must not be more than 25 characters.
557
-
558
- Endpoints without correct scheme or scope assignments are not registered.
559
-
560
- ### 3.3 Requesting Endpoints
561
-
562
- #### ShopperLogin
563
-
564
- Scopes for ShopperLogin can be assigned to a client in the SLAS Admin UI. For example:
565
-
566
- > Custom API SLAS scope configuration and permissions
567
-
568
- To obtain a SLAS token, follow the steps in the Shopper Login overview.
569
-
570
- #### AmOAuth2
571
-
572
- Custom scopes for AmOAuth2 can be assigned to a client in Account Manager. For example:
573
-
574
- > Account Manager OAuth2 scopes configuration for Custom APIs
575
-
576
- To obtain an Account Manager token follow the steps in the Authorization for Admin APIs guide.
577
-
578
- Unauthorized requests receive a 401 Unauthorized response.
579
-
580
- ### 3.4 Complete Security Scheme Definition
581
-
582
- While endpoint registration does not require the complete definition of the security schemes, it can be useful to have a complete and valid scheme to enable the creation of documentation, tests and code stubs, and mock requests. The following code provides a complete example:
583
-
584
- ```yaml
585
- components:
586
- securitySchemes:
587
- ShopperToken:
588
- type: oauth2
589
- flows:
590
- authorizationCode:
591
- authorizationUrl: https://my-shortcode.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/authorize
592
- tokenUrl: https://my-shortcode.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/token
593
- scopes:
594
- c_my-scopes: description of my-scopes
595
- clientCredentials:
596
- tokenUrl: https://my-shortcode.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/{organizationId}/oauth2/token
597
- scopes:
598
- c_my-scopes: description of my-scopes
599
- AmOAuth2:
600
- type: oauth2
601
- flows:
602
- authorizationCode:
603
- authorizationUrl: https://account.demandware.com/dwsso/oauth2/authorize
604
- tokenUrl: https://account.demandware.com/dwsso/oauth2/access_token
605
- scopes:
606
- c_my-scopes: description of my-scopes
607
- clientCredentials:
608
- tokenUrl: https://account.demandware.com/dwsso/oauth2/access_token
609
- scopes:
610
- c_my-scopes: description of my-scopes
611
- ```
612
-
613
- ## 4. Core Concept: The Three Pillars of a Custom API
614
-
615
- Every Custom SCAPI Endpoint is built from three mandatory files, located within a dedicated cartridge directory: `your_cartridge/cartridge/rest-apis/{api-name}/`.
616
-
617
- - **`schema.yaml` (The Contract)**: An OpenAPI 3.0 specification that defines the endpoint's URL path, HTTP method, parameters, security requirements, and response models. SCAPI uses this for automated request validation.
618
-
619
- - **`script.js` (The Logic)**: A server-side B2C Commerce script (`dw.*` packages) that contains the business logic. It must export a public function with a name that exactly matches the `operationId` in the schema.
620
-
621
- - **`api.json` (The Mapping)**: A simple JSON file that links the `operationId` from the schema to the correct implementation script.
622
-
623
- ## 5. Quick Start Example: A "Loyalty Info" Endpoint
624
-
625
- Here is a complete example for a custom Shopper API endpoint `GET /custom/loyalty-api/v1/.../loyalty-info?c_customer_id={id}`.
626
-
627
- ### Directory Structure
628
-
629
- ```
630
- int_loyalty_api/
631
- └── cartridge/
632
- └── rest-apis/
633
- └── loyalty-api/
634
- ├── schema.yaml
635
- ├── loyalty.js
636
- └── api.json
637
- ```
638
-
639
- ### `schema.yaml`
640
-
641
- ```yaml
642
- openapi: 3.0.0
643
- info:
644
- title: Loyalty Information API
645
- version: "1.0.0" # Becomes /v1/ in the URL
646
- paths:
647
- /loyalty-info:
648
- get:
649
- summary: Retrieves loyalty points for a customer.
650
- operationId: getLoyaltyInfo # Must match the exported function name
651
- parameters:
652
- - name: siteId # Required for Shopper APIs
653
- in: query
654
- required: true
655
- schema:
656
- type: string
657
- minLength: 1
658
- - name: c_customer_id # Custom parameters must be prefixed with 'c_'
659
- in: query
660
- required: true
661
- schema:
662
- type: string
663
- responses:
664
- '200':
665
- description: Successful retrieval of loyalty information.
666
- content:
667
- application/json:
668
- schema:
669
- $ref: '#/components/schemas/LoyaltyInfo'
670
- '404':
671
- description: Customer not found.
672
- security:
673
- - ShopperToken: [c_read_loyalty] # Apply security scheme and custom scope
674
- components:
675
- schemas:
676
- LoyaltyInfo:
677
- type: object
678
- properties:
679
- tier:
680
- type: string
681
- points:
682
- type: integer
683
- securitySchemes:
684
- ShopperToken: # Define the security scheme for Shopper APIs
685
- type: oauth2
686
- flows:
687
- clientCredentials:
688
- tokenUrl: https://my-shortcode.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/my-org-id/oauth2/token
689
- scopes:
690
- c_read_loyalty: "Read access to loyalty data." # Define custom scope
691
- ```
692
-
693
- ### `loyalty.js`
694
-
695
- ```javascript
696
- 'use strict';
697
-
698
- var RESTResponseMgr = require('dw/system/RESTResponseMgr');
699
- var CustomerMgr = require('dw/customer/CustomerMgr');
700
-
701
- /**
702
- * Implements the getLoyaltyInfo operationId.
703
- */
704
- exports.getLoyaltyInfo = function () {
705
- var customerId = request.getHttpParameterMap().get('c_customer_id').getStringValue();
706
- var customer = CustomerMgr.getCustomerByCustomerNumber(customerId);
707
-
708
- // IMPORTANT: Add fine-grained authorization check here.
709
- // e.g., verify request.user.profile.customerNo === customerId
710
-
711
- if (customer) {
712
- var loyaltyData = {
713
- tier: 'Gold',
714
- points: 25800
715
- };
716
- RESTResponseMgr.createSuccess(loyaltyData).render();
717
- } else {
718
- RESTResponseMgr.createError(404, "customer-not-found", "Customer Not Found", "Customer ID is unknown.").render();
719
- }
720
- };
721
-
722
- // Function must be public to be exposed as an endpoint
723
- exports.getLoyaltyInfo.public = true;
724
- ```
725
-
726
- ### `api.json`
727
-
728
- ```json
729
- {
730
- "endpoints": [
731
- {
732
- "endpoint": "getLoyaltyInfo",
733
- "schema": "schema.yaml",
734
- "implementation": "loyalty"
735
- }
736
- ]
737
- }
738
- ```
739
-
740
- ## 5.1 Working with Path Parameters
741
-
742
- When your OpenAPI schema defines parameters with `in: path`, you must use the `getSCAPIPathParameters()` method to access them in your script implementation.
743
-
744
- ### Path Parameter Example
745
-
746
- **schema.yaml with path parameter:**
747
- ```yaml
748
- openapi: 3.0.0
749
- info:
750
- title: Product Reviews API
751
- version: "1.0.0"
752
- paths:
753
- /products/{productId}/reviews:
754
- get:
755
- summary: Get reviews for a specific product
756
- operationId: getProductReviews
757
- parameters:
758
- - name: productId
759
- in: path # This is a path parameter
760
- required: true
761
- schema:
762
- type: string
763
- - name: siteId
764
- in: query
765
- required: true
766
- schema:
767
- type: string
768
- responses:
769
- '200':
770
- description: Product reviews retrieved successfully
771
- content:
772
- application/json:
773
- schema:
774
- type: array
775
- items:
776
- $ref: '#/components/schemas/Review'
777
- components:
778
- schemas:
779
- Review:
780
- type: object
781
- properties:
782
- id:
783
- type: string
784
- rating:
785
- type: integer
786
- comment:
787
- type: string
788
- ```
789
-
790
- **script.js accessing path parameter:**
791
- ```javascript
792
- 'use strict';
793
-
794
- var RESTResponseMgr = require('dw/system/RESTResponseMgr');
795
- var ProductMgr = require('dw/catalog/ProductMgr');
796
-
797
- /**
798
- * Implements the getProductReviews operationId.
799
- */
800
- exports.getProductReviews = function () {
801
- // Access path parameters using getSCAPIPathParameters()
802
- var productId = request.getSCAPIPathParameters().get('productId');
803
-
804
- // Access query parameters using getHttpParameterMap()
805
- var siteId = request.getHttpParameterMap().get('siteId').getStringValue();
806
-
807
- // Validate required path parameter
808
- if (!productId) {
809
- RESTResponseMgr.createError(400, "missing-product-id",
810
- "Missing Product ID", "Product ID is required in the path").render();
811
- return;
812
- }
813
-
814
- var product = ProductMgr.getProduct(productId);
815
- if (!product) {
816
- RESTResponseMgr.createError(404, "product-not-found",
817
- "Product Not Found", "Product with ID " + productId + " was not found").render();
818
- return;
819
- }
820
-
821
- // Business logic to fetch reviews
822
- var reviews = [
823
- {
824
- id: "review-1",
825
- rating: 5,
826
- comment: "Excellent product!"
827
- },
828
- {
829
- id: "review-2",
830
- rating: 4,
831
- comment: "Good quality, fast shipping"
832
- }
833
- ];
834
-
835
- RESTResponseMgr.createSuccess(reviews).render();
836
- };
837
-
838
- exports.getProductReviews.public = true;
839
- ```
840
-
841
- ### Key Points for Path Parameters
842
-
843
- 1. **Path Parameter Access**: Always use `request.getSCAPIPathParameters().get('parameterName')` for parameters defined with `in: path` in your OpenAPI schema.
844
-
845
- 2. **Query Parameter Access**: Continue using `request.getHttpParameterMap().get('parameterName')` for parameters defined with `in: query`.
846
-
847
- 3. **Parameter Validation**: Path parameters are automatically validated by SCAPI based on your schema, but you should still add business logic validation in your script.
848
-
849
- 4. **URL Structure**: Path parameters become part of the URL structure. For example, `/products/{productId}/reviews` with `productId: "ABC123"` becomes `/products/ABC123/reviews`.
850
-
851
- 5. **Multiple Path Parameters**: You can have multiple path parameters in a single endpoint:
852
- ```yaml
853
- paths:
854
- /customers/{customerId}/orders/{orderId}:
855
- get:
856
- parameters:
857
- - name: customerId
858
- in: path
859
- required: true
860
- - name: orderId
861
- in: path
862
- required: true
863
- ```
864
-
865
- Access them individually:
866
- ```javascript
867
- var customerId = request.getSCAPIPathParameters().get('customerId');
868
- var orderId = request.getSCAPIPathParameters().get('orderId');
869
- ```
870
-
871
-
872
- ## 5.2 Caching Strategies for Custom Endpoints
873
-
874
- ### Platform Web-Tier Behavior
875
-
876
- - Commerce Cloud's application layer performs web-tier caching for **GET** requests across SCAPI API families. Custom endpoints participate automatically once a request reaches the platform.
877
- - Client-side caches (browser storage, SPA state, CDN/edge caches) continue to operate independently. Model your architecture with layered caches in mind so one layer's miss does not surprise you at runtime.
878
-
879
- ### Personalized Cache Variants
880
-
881
- When personalization is enabled, the cache key is expanded with:
882
-
883
- - The complete set of active promotions
884
- - Active product sorting rules
885
- - Applicable price books
886
- - All active AB test groups
887
-
888
- That means two shoppers requesting the same URL can receive different cache entries if they fall into different promotional contexts (for example, promotion X vs. promotion Y). This is valuable for targeted experiences but increases cache cardinality. Use personalization only for well-sized shopper cohorts and monitor cache pressure.
889
-
890
- `response.setVaryBy('price_promotion')` is the only supported personalization flag. Product detail responses that expand prices or promotions—and product search responses with the `prices` expand—are already personalized by default.
891
-
892
- ### Programmatic Cache Controls
893
-
894
- - `response.setExpires(Date.now() + ttlInMs)`: Sets the cache expiration timestamp. The TTL must be at least **1 second (1,000 ms)** and no more than **86,400 seconds (86,400,000 ms)**.
895
- - `response.setVaryBy('price_promotion')`: Opts into price/promotion-aware personalization for the response variant.
896
-
897
- ```javascript
898
- // Example snippet within your endpoint script
899
- exports.getLoyaltyInfo = function (params) {
900
- var loyaltyData = { id: params.c_customer_id, points: 1234 };
901
-
902
- // Cache for five minutes and personalize by price/promotion eligibility when needed
903
- response.setExpires(Date.now() + 5 * 60 * 1000);
904
- // response.setVaryBy('price_promotion');
905
-
906
- RESTResponseMgr.createSuccess(loyaltyData).render();
907
- };
908
- exports.getLoyaltyInfo.public = true;
909
- ```
910
-
911
- ### Cache-Key Design Tips
912
-
913
- - Introduce explicit query parameters (for example, `c_view=light`) when you need multiple cacheable variants from the same controller logic.
914
- - Avoid combining expansions with drastically different TTLs. The response inherits the **shortest** TTL from the set of requested expands, so pairing a 24-hour asset expand with a 60-second availability expand collapses the lifespan to 60 seconds.
915
- - Pair web-tier caching with application-tier caching (`CacheMgr.getCache().get(key, loader)`) to shield downstream services. See the Performance Best Practices guide for the full two-tier pattern.
916
-
917
- ## 6. Core Best Practices
918
-
919
- ### Design & Architecture
920
-
921
- **Shopper vs. Admin APIs**: Choose the correct type for your use case. This choice is critical and dictates security, required parameters, and performance limits.
922
-
923
- - **Shopper API**: For customer-facing applications. Requires `siteId` parameter. Secured by ShopperToken (SLAS). 10-second timeout.
924
- - **Admin API**: For merchant tools. Must not have `siteId`. Secured by AmOAuth2 (Account Manager). 60-second timeout.
925
-
926
- **BFF Pattern**: Create endpoints that aggregate data for specific UI components to reduce the number of client-side calls and improve performance.
927
-
928
- ### Security
929
-
930
- - **Custom Scopes**: Every endpoint must be secured by exactly one custom scope defined in the `schema.yaml`. Scope names must start with `c_` (e.g., `c_read_loyalty`).
931
- - **Client Permissions**: The API client in SLAS (for Shopper) or Account Manager (for Admin) must be granted permission to use your custom scope.
932
- - **In-Script Authorization**: The platform validates the token and scope. You must validate that the authenticated user has permission to access the specific data they are requesting. This prevents privilege escalation attacks.
933
-
934
- ### Performance
935
-
936
- - **Timeouts**: Respect the hard timeouts: 10 seconds for Shopper APIs and 60 seconds for Admin APIs.
937
- - **Efficient Scripting**: Avoid expensive API calls (e.g., `ProductMgr.getProduct()`) inside loops. Fetch data in bulk where possible.
938
- - **External Calls**: Use the Service Framework (`dw.svc.*`) for any third-party callouts. Set aggressive timeouts and enable the circuit breaker to prevent cascading failures.
939
- - **Caching**: Use Custom Caches (`dw.system.CacheMgr`) for data that is expensive to compute but doesn't change often.
940
-
941
- ### Versioning
942
-
943
- - The URL version (e.g., `/v1/`) is automatically derived from the major version number in your `schema.yaml`'s `info.version` field (e.g., "1.0.0" or "1.2.5" both map to v1).
944
- - Introduce breaking changes (e.g., removing a field, changing a data type) in a new major version (e.g., 2.0.0 -> `/v2/`) to avoid disrupting existing clients.
945
-
946
- ### Troubleshooting
947
-
948
- - **404 Not Found**: This almost always means the API failed to register. Systematically check your cartridge structure, file names, `operationId` matching, and `api.json` syntax.
949
- - **403 Forbidden**: The client's token is valid but is missing the required custom scope. Check the scope assignments in SLAS or Account Manager.
950
- - **504 Gateway Timeout**: Your script exceeded the performance limit. Use the Code Profiler to find and optimize the bottleneck in your code.
951
-
952
-
953
- ## 7. Custom APIs vs. Hooks
954
-
955
- This is a critical architectural decision.
956
-
957
- - **Use Hooks to...** modify or augment the behavior of an existing, out-of-the-box SCAPI endpoint. For example, adding a custom attribute to the standard `/baskets` response.
958
-
959
- - **Use Custom APIs to...** create entirely new functionality that has no OOTB equivalent. For example, a store locator, a loyalty points service, or a newsletter signup endpoint.
960
-
961
- > **Note**: Choosing the wrong tool leads to technical debt. Do not use hooks to create net-new functionality.
962
-
963
- ---