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,1142 +0,0 @@
1
- # Salesforce B2C Commerce SFRA Models: Best Practices & Implementation Guide
2
-
3
- This guide provides comprehensive best practices for creating, extending, and customizing models within the Salesforce B2C Commerce Storefront Reference Architecture (SFRA). Models are the JSON object layer that converts B2C Commerce Script API objects into pure JSON designed for storefront rendering.
4
-
5
- **IMPORTANT**: Before developing SFRA models, consult the **Performance and Stability Best Practices** guide from this MCP server. Review database optimization guidelines and index-friendly API usage to ensure your models follow SFCC performance standards.
6
-
7
- ## 🚀 Enhanced SFRA Model Documentation Access
8
-
9
- This MCP server provides comprehensive access to SFRA model documentation through enhanced tools that can help you understand existing models and develop better custom ones:
10
-
11
- ### **Essential SFRA Model Documentation Tools**
12
-
13
- 1. **`get_sfra_categories`** - Discover all available SFRA documentation categories including models
14
- 2. **`get_sfra_documents_by_category`** - Explore model documents by functional area:
15
- - `product` - Product models including product-full, product-tile, product-bundle
16
- - `order` - Cart, billing, shipping, payment, totals models
17
- - `customer` - Account, address models
18
- - `pricing` - Price models for different pricing scenarios
19
- - `store` - Store and location models
20
-
21
- 3. **`get_sfra_document`** - Get detailed information about specific SFRA models
22
- 4. **`search_sfra_documentation`** - Find specific model functionality across all documentation
23
-
24
- ### **Recommended Model Documentation Workflow**
25
-
26
- Before creating or extending models, use these tools to understand existing model patterns:
27
-
28
- ```javascript
29
- // 1. Explore all available model categories
30
- get_sfra_categories()
31
-
32
- // 2. Examine product models for complex data structures
33
- get_sfra_documents_by_category("product")
34
- get_sfra_document("product-full") // Comprehensive product model
35
-
36
- // 3. Study cart and order models for business logic patterns
37
- get_sfra_documents_by_category("order")
38
- get_sfra_document("cart") // Complex cart model with totals and line items
39
-
40
- // 4. Review customer models for profile management
41
- get_sfra_documents_by_category("customer")
42
- get_sfra_document("account") // Customer account model
43
-
44
- // 5. Search for specific model functionality
45
- search_sfra_documentation("decorator")
46
- search_sfra_documentation("model")
47
- ```
48
-
49
- ## Core Model Concepts
50
-
51
- ### What Are SFRA Models?
52
-
53
- SFRA models serve as a JSON transformation layer that:
54
-
55
- - **Convert** SFCC Script API objects into pure JSON objects
56
- - **Apply** business logic specific to the storefront
57
- - **Structure** data for optimal template rendering
58
- - **Provide** a consistent interface between controllers and views
59
-
60
- Models are passed to templates via the `viewData` variable (accessible as `pdict` in templates).
61
-
62
- ### Model Design Principles
63
-
64
- 1. **Pure JSON Output**: Models should return only JSON-serializable data
65
- 2. **Single Responsibility**: Each model should handle one specific domain
66
- 3. **Composability**: Models should be easily combinable and extensible
67
- 4. **Performance**: Minimize API calls and database queries within models
68
- 5. **Testability**: Models should be unit-testable with mock data
69
-
70
- ## Default SFRA Model Project Structure
71
-
72
- Understanding the default SFRA model structure is essential for building consistent and maintainable e-commerce applications. The base SFRA cartridge (`app_storefront_base`) provides a comprehensive model library that follows established patterns and conventions.
73
-
74
- ### Directory Organization
75
-
76
- ```
77
- cartridge/models/
78
- ├── account.js # Customer account model
79
- ├── address.js # Address transformation model
80
- ├── billing.js # Billing information model
81
- ├── cart.js # Shopping cart model with totals
82
- ├── categories.js # Category navigation model
83
- ├── content.js # Content asset model
84
- ├── locale.js # Locale and currency model
85
- ├── order.js # Order model for order history
86
- ├── payment.js # Payment instrument model
87
- ├── productLineItems.js # Collection of product line items
88
- ├── shipping.js # Shipping address and methods
89
- ├── store.js # Individual store model
90
- ├── stores.js # Store locator collection model
91
- ├── totals.js # Order/cart totals calculation model
92
- ├── price/ # Price-related models
93
- │ ├── default.js # Standard price model
94
- │ ├── range.js # Price range model (min-max)
95
- │ └── tiered.js # Tiered pricing model
96
- ├── product/ # Product-related models
97
- │ ├── bonusProduct.js # Bonus/promotional product model
98
- │ ├── fullProduct.js # Complete product details model
99
- │ ├── productAttributes.js # Product attributes model
100
- │ ├── productBundle.js # Product bundle model
101
- │ ├── productImages.js # Product images model
102
- │ ├── productSet.js # Product set model
103
- │ ├── productTile.js # Product tile/listing model
104
- │ └── decorators/ # Product decorator functions
105
- │ ├── index.js # Decorator registry
106
- │ ├── attributes.js # Product attributes decorator
107
- │ ├── availability.js # Stock availability decorator
108
- │ ├── base.js # Core product information
109
- │ ├── bonusUnitPrice.js # Bonus pricing decorator
110
- │ ├── bundleReadyToOrder.js # Bundle ordering readiness
111
- │ ├── bundledProducts.js # Bundle component products
112
- │ ├── currentUrl.js # Product URL decorator
113
- │ ├── description.js # Product description decorator
114
- │ ├── images.js # Product images decorator
115
- │ ├── online.js # Online availability decorator
116
- │ ├── options.js # Product options decorator
117
- │ ├── pageMetaData.js # SEO metadata decorator
118
- │ ├── price.js # Price calculation decorator
119
- │ ├── promotions.js # Promotional pricing decorator
120
- │ ├── quantity.js # Quantity handling decorator
121
- │ ├── quantitySelector.js # Quantity selector decorator
122
- │ ├── ratings.js # Product ratings decorator
123
- │ ├── raw.js # Raw API object decorator
124
- │ ├── readyToOrder.js # Order readiness decorator
125
- │ ├── searchPrice.js # Search result pricing
126
- │ ├── searchVariationAttributes.js # Search variation handling
127
- │ ├── setIndividualProducts.js # Product set individuals
128
- │ ├── setProductsCollection.js # Product set collection
129
- │ ├── setReadyToOrder.js # Set ordering readiness
130
- │ ├── sizeChart.js # Size chart decorator
131
- │ ├── template.js # Template selection decorator
132
- │ └── variationAttributes.js # Variation attributes decorator
133
- ├── productLineItem/ # Product line item models
134
- │ ├── bonusOrderLineItem.js # Bonus order line item
135
- │ ├── bonusProductLineItem.js # Bonus product line item
136
- │ ├── bundleLineItem.js # Bundle line item model
137
- │ ├── bundleOrderLineItem.js # Bundle order line item
138
- │ ├── orderLineItem.js # Order line item model
139
- │ ├── productLineItem.js # Cart line item model
140
- │ └── decorators/ # Line item decorators
141
- │ ├── index.js # Decorator registry
142
- │ ├── appliedPromotions.js # Applied promotion decorator
143
- │ ├── bonusProductLineItem.js # Bonus product decorator
144
- │ ├── bonusProductLineItemUUID.js # Bonus UUID decorator
145
- │ ├── bonusUnitPrice.js # Bonus pricing decorator
146
- │ ├── bundledProductLineItems.js # Bundle items decorator
147
- │ ├── discountBonusLineItems.js # Discount bonus decorator
148
- │ ├── gift.js # Gift message decorator
149
- │ ├── options.js # Line item options decorator
150
- │ ├── orderable.js # Orderability decorator
151
- │ ├── preOrderUUID.js # Pre-order UUID decorator
152
- │ ├── priceTotal.js # Price total decorator
153
- │ ├── quantity.js # Quantity decorator
154
- │ ├── quantityOptions.js # Quantity options decorator
155
- │ ├── renderedPromotions.js # Rendered promotions decorator
156
- │ ├── shipment.js # Shipment decorator
157
- │ └── uuid.js # UUID decorator
158
- ├── search/ # Search-related models
159
- │ ├── contentSearch.js # Content search results model
160
- │ ├── productSearch.js # Product search results model
161
- │ ├── productSortOptions.js # Sort options model
162
- │ ├── attributeRefinementValue/ # Search refinement models
163
- │ └── suggestions/ # Search suggestion models
164
- └── shipping/ # Shipping-related models
165
- └── shippingMethod.js # Shipping method model
166
- ```
167
-
168
- ### Key Model Categories
169
-
170
- #### **1. Core Commerce Models**
171
- - **`cart.js`** - Central shopping cart model with totals, line items, and promotions
172
- - **`order.js`** - Order model for order history and confirmation pages
173
- - **`account.js`** - Customer account information and preferences
174
- - **`payment.js`** - Payment instruments and billing information
175
-
176
- #### **2. Product Models**
177
- - **`product/fullProduct.js`** - Complete product details for PDP
178
- - **`product/productTile.js`** - Lightweight product info for listings
179
- - **`product/productBundle.js`** - Bundle product handling
180
- - **`product/decorators/`** - Modular product enhancement functions
181
-
182
- #### **3. Line Item Models**
183
- - **`productLineItem/productLineItem.js`** - Cart line items
184
- - **`productLineItem/orderLineItem.js`** - Order line items
185
- - **`productLineItem/decorators/`** - Line item enhancement functions
186
-
187
- #### **4. Pricing Models**
188
- - **`price/default.js`** - Standard pricing model
189
- - **`price/range.js`** - Price range for variable pricing
190
- - **`price/tiered.js`** - Volume-based pricing tiers
191
- - **`totals.js`** - Cart/order total calculations
192
-
193
- #### **5. Location & Shipping Models**
194
- - **`store.js`** & **`stores.js`** - Store locator functionality
195
- - **`shipping.js`** - Shipping address and method selection
196
- - **`address.js`** - Address transformation and validation
197
-
198
- #### **6. Search Models**
199
- - **`search/productSearch.js`** - Search results and refinements
200
- - **`search/contentSearch.js`** - Content search functionality
201
- - **`search/productSortOptions.js`** - Sorting options for search
202
-
203
- ### Model Inheritance Patterns
204
-
205
- The SFRA model structure follows several key patterns:
206
-
207
- #### **Decorator Pattern** (Product Models)
208
- ```javascript
209
- // product/decorators/index.js - Central decorator registry
210
- module.exports = {
211
- base: require('*/cartridge/models/product/decorators/base'),
212
- price: require('*/cartridge/models/product/decorators/price'),
213
- images: require('*/cartridge/models/product/decorators/images'),
214
- // ... other decorators
215
- };
216
-
217
- // Usage in fullProduct.js
218
- var decorators = require('*/cartridge/models/product/decorators/index');
219
- function fullProduct(product, apiProduct, options) {
220
- decorators.base(product, apiProduct, options.productType);
221
- decorators.price(product, apiProduct, options.promotions);
222
- decorators.images(product, apiProduct, options);
223
- return product;
224
- }
225
- ```
226
-
227
- #### **Composition Pattern** (Complex Models)
228
- ```javascript
229
- // cart.js - Composes multiple sub-models
230
- var TotalsModel = require('*/cartridge/models/totals');
231
- var ProductLineItemsModel = require('*/cartridge/models/productLineItems');
232
-
233
- function Cart(basket) {
234
- this.totals = new TotalsModel(basket);
235
- this.items = new ProductLineItemsModel(basket.productLineItems);
236
- this.shipments = createShipmentModels(basket.shipments);
237
- }
238
- ```
239
-
240
- #### **Factory Pattern** (Conditional Models)
241
- ```javascript
242
- // Different models based on product type
243
- function createProductModel(apiProduct, type) {
244
- switch (type) {
245
- case 'full': return require('*/cartridge/models/product/fullProduct');
246
- case 'tile': return require('*/cartridge/models/product/productTile');
247
- case 'bundle': return require('*/cartridge/models/product/productBundle');
248
- }
249
- }
250
- ```
251
-
252
- ### Best Practices for Structure
253
-
254
- 1. **Follow the Directory Convention**: Maintain the same directory structure in custom cartridges
255
- 2. **Use Decorator Registries**: Create `index.js` files to register and export decorators
256
- 3. **Separate Concerns**: Keep pricing, images, and availability in separate decorators
257
- 4. **Maintain Model Hierarchy**: Extend base models rather than replacing entirely
258
- 5. **Consistent Naming**: Follow SFRA naming conventions for predictable imports
259
-
260
- This structure provides a solid foundation for building scalable, maintainable e-commerce models that integrate seamlessly with the SFRA framework.
261
-
262
- ## Model Architecture Patterns
263
-
264
- ### 1. Simple Data Models
265
-
266
- Basic models that transform API objects into JSON structures:
267
-
268
- ```javascript
269
- 'use strict';
270
-
271
- /**
272
- * Address Model - Transforms dw.customer.OrderAddress into JSON
273
- * @param {dw.customer.OrderAddress} addressObject - Address from SFCC API
274
- * @constructor
275
- */
276
- function Address(addressObject) {
277
- if (addressObject) {
278
- this.address = {
279
- firstName: addressObject.firstName,
280
- lastName: addressObject.lastName,
281
- address1: addressObject.address1,
282
- address2: addressObject.address2,
283
- city: addressObject.city,
284
- postalCode: addressObject.postalCode,
285
- stateCode: addressObject.stateCode,
286
- countryCode: addressObject.countryCode.value,
287
- phone: addressObject.phone
288
- };
289
- }
290
- }
291
-
292
- module.exports = Address;
293
- ```
294
-
295
- ### 2. Decorator Pattern Models
296
-
297
- Complex models using the decorator pattern for modular composition:
298
-
299
- ```javascript
300
- 'use strict';
301
-
302
- var decorators = require('*/cartridge/models/product/decorators/index');
303
-
304
- /**
305
- * Full Product Model using Decorator Pattern
306
- * @param {dw.catalog.Product} apiProduct - Product from SFCC API
307
- * @param {Object} options - Configuration options
308
- * @returns {Object} - Decorated product model
309
- */
310
- function fullProduct(product, apiProduct, options) {
311
- // Base product information
312
- decorators.base(product, apiProduct, options.productType);
313
-
314
- // Price information with promotions
315
- decorators.price(product, apiProduct, options.promotions, false, options.optionModel);
316
-
317
- // Images with different sizes
318
- if (options.variationModel) {
319
- decorators.images(product, options.variationModel, {
320
- types: ['large', 'small'],
321
- quantity: 'all'
322
- });
323
- } else {
324
- decorators.images(product, apiProduct, {
325
- types: ['large', 'small'],
326
- quantity: 'all'
327
- });
328
- }
329
-
330
- // Additional decorators for complete product information
331
- decorators.quantity(product, apiProduct, options.quantity);
332
- decorators.variationAttributes(product, options.variationModel, {
333
- attributes: '*',
334
- endPoint: 'Variation'
335
- });
336
- decorators.description(product, apiProduct);
337
- decorators.ratings(product);
338
- decorators.promotions(product, options.promotions);
339
- decorators.attributes(product, apiProduct.attributeModel);
340
- decorators.availability(product, options.quantity, apiProduct.minOrderQuantity.value, apiProduct.availabilityModel);
341
- decorators.options(product, options.optionModel, options.variables, options.quantity);
342
-
343
- return product;
344
- }
345
-
346
- module.exports = fullProduct;
347
- ```
348
-
349
- **⚠️ CRITICAL DECORATOR WARNING**
350
-
351
- **NEVER** create decorators that return a new object or use `Object.assign()` to clone the product. This breaks the SFRA model pattern and causes unpredictable behavior:
352
-
353
- ```javascript
354
- // ❌ WRONG: Never do this in a decorator
355
- module.exports = function randomString(product) {
356
- var decoratedProduct = Object.assign({}, product);
357
- decoratedProduct.randomString = Math.random().toString(36).substring(2, 15);
358
- return decoratedProduct; // This breaks the model!
359
- };
360
- ```
361
-
362
- **Why this breaks models:**
363
- - Decorators should **mutate** the original product object, not create copies
364
- - Returning a new object breaks the reference chain between decorators
365
- - Subsequent decorators will operate on the wrong object
366
- - The final model will be incomplete or corrupted
367
-
368
- ```javascript
369
- // ✅ CORRECT: Mutate the original object
370
- module.exports = function randomString(product) {
371
- product.randomString = Math.random().toString(36).substring(2, 15);
372
- // No return statement - decorators modify in place
373
- };
374
- ```
375
-
376
- **Decorator Best Practices:**
377
- 1. **Mutate, don't clone** - Always modify the passed product object directly
378
- 2. **No return values** - Decorators should not return anything
379
- 3. **Side effects only** - Decorators should only add/modify properties
380
- 4. **Reference preservation** - Keep the original object reference intact
381
-
382
- ### 3. Factory Pattern Models
383
-
384
- Models that create different types based on input:
385
-
386
- ```javascript
387
- 'use strict';
388
-
389
- var ProductFactory = require('*/cartridge/scripts/factories/product');
390
- var fullProduct = require('*/cartridge/models/product/fullProduct');
391
- var productTile = require('*/cartridge/models/product/productTile');
392
-
393
- /**
394
- * Product Model Factory
395
- * @param {dw.catalog.Product} apiProduct - Product from API
396
- * @param {Object} options - Configuration options
397
- * @param {string} type - Model type ('full', 'tile', 'bundle')
398
- * @returns {Object} - Appropriate product model
399
- */
400
- function create(apiProduct, options, type) {
401
- var product = {};
402
-
403
- switch (type) {
404
- case 'full':
405
- return fullProduct(product, apiProduct, options);
406
- case 'tile':
407
- return productTile(product, apiProduct, options);
408
- case 'bundle':
409
- return bundleProduct(product, apiProduct, options);
410
- default:
411
- return fullProduct(product, apiProduct, options);
412
- }
413
- }
414
-
415
- module.exports = {
416
- get: create
417
- };
418
- ```
419
-
420
- ## Model Customization Strategies
421
-
422
- ### 1. Extending Base Models
423
-
424
- Override base models by creating a model with the same name in your custom cartridge:
425
-
426
- ```javascript
427
- 'use strict';
428
-
429
- // Import the base model
430
- var base = module.superModule;
431
-
432
- /**
433
- * Extended Account Model with additional customer data
434
- * @param {dw.customer.Customer} currentCustomer - Current customer
435
- * @param {Object} addressBook - Customer's address book
436
- * @param {Object} orderHistory - Customer's order history
437
- * @constructor
438
- */
439
- function Account(currentCustomer, addressBook, orderHistory) {
440
- // Call base constructor
441
- base.call(this, currentCustomer, addressBook, orderHistory);
442
-
443
- // Add custom properties
444
- this.loyaltyProgram = getLoyaltyProgram(currentCustomer);
445
- this.preferences = getCustomerPreferences(currentCustomer);
446
- this.communicationPreferences = getCommunicationPreferences(currentCustomer);
447
- }
448
-
449
- /**
450
- * Get customer loyalty program information
451
- * @param {dw.customer.Customer} customer - Customer object
452
- * @returns {Object} Loyalty program data
453
- */
454
- function getLoyaltyProgram(customer) {
455
- if (customer && customer.profile && customer.profile.custom.loyaltyNumber) {
456
- return {
457
- number: customer.profile.custom.loyaltyNumber,
458
- tier: customer.profile.custom.loyaltyTier || 'Bronze',
459
- points: customer.profile.custom.loyaltyPoints || 0
460
- };
461
- }
462
- return null;
463
- }
464
-
465
- /**
466
- * Get customer preferences
467
- * @param {dw.customer.Customer} customer - Customer object
468
- * @returns {Object} Customer preferences
469
- */
470
- function getCustomerPreferences(customer) {
471
- if (customer && customer.profile) {
472
- return {
473
- language: customer.profile.custom.preferredLanguage || 'en',
474
- currency: customer.profile.custom.preferredCurrency || 'USD',
475
- newsletter: customer.profile.custom.newsletterSubscription || false
476
- };
477
- }
478
- return {};
479
- }
480
-
481
- module.exports = Account;
482
- ```
483
-
484
- ### 2. Creating New Decorators
485
-
486
- Add new functionality through custom decorators:
487
-
488
- ```javascript
489
- 'use strict';
490
-
491
- /**
492
- * Social Media Decorator - Adds social sharing data to product
493
- * @param {Object} product - Product model to decorate
494
- * @param {dw.catalog.Product} apiProduct - Product from API
495
- */
496
- module.exports = function socialMedia(product, apiProduct) {
497
- var URLUtils = require('dw/web/URLUtils');
498
- var Site = require('dw/system/Site');
499
-
500
- var socialData = {};
501
-
502
- // Facebook sharing
503
- socialData.facebook = {
504
- url: URLUtils.https('Product-Show', 'pid', apiProduct.ID).toString(),
505
- title: apiProduct.name,
506
- description: apiProduct.shortDescription ? apiProduct.shortDescription.markup : '',
507
- image: getProductImage(apiProduct, 'large')
508
- };
509
-
510
- // Twitter sharing
511
- socialData.twitter = {
512
- url: URLUtils.https('Product-Show', 'pid', apiProduct.ID).toString(),
513
- text: apiProduct.name + ' - ' + Site.getCurrent().getName(),
514
- hashtags: getProductHashtags(apiProduct)
515
- };
516
-
517
- // Pinterest sharing
518
- socialData.pinterest = {
519
- url: URLUtils.https('Product-Show', 'pid', apiProduct.ID).toString(),
520
- description: apiProduct.name,
521
- media: getProductImage(apiProduct, 'large')
522
- };
523
-
524
- Object.defineProperty(product, 'social', {
525
- enumerable: true,
526
- value: socialData
527
- });
528
- };
529
-
530
- /**
531
- * Get product image for social sharing
532
- * @param {dw.catalog.Product} apiProduct - Product from API
533
- * @param {string} size - Image size
534
- * @returns {string} Image URL
535
- */
536
- function getProductImage(apiProduct, size) {
537
- var images = apiProduct.getImages(size);
538
- return images.length > 0 ? images[0].getURL().toString() : '';
539
- }
540
-
541
- /**
542
- * Generate hashtags from product attributes
543
- * @param {dw.catalog.Product} apiProduct - Product from API
544
- * @returns {string} Comma-separated hashtags
545
- */
546
- function getProductHashtags(apiProduct) {
547
- var hashtags = [];
548
-
549
- if (apiProduct.brand) {
550
- hashtags.push(apiProduct.brand.replace(/\s+/g, ''));
551
- }
552
-
553
- if (apiProduct.primaryCategory) {
554
- hashtags.push(apiProduct.primaryCategory.displayName.replace(/\s+/g, ''));
555
- }
556
-
557
- return hashtags.join(',');
558
- }
559
- ```
560
-
561
- ### 3. Adding Custom Properties to Existing Models
562
-
563
- Use controller logic to extend models without modifying base files:
564
-
565
- ```javascript
566
- 'use strict';
567
-
568
- var server = require('server');
569
- var ProductMgr = require('dw/catalog/ProductMgr');
570
- var ProductFactory = require('*/cartridge/scripts/factories/product');
571
-
572
- server.get('Show', function (req, res, next) {
573
- var productId = req.querystring.pid;
574
- var product = ProductMgr.getProduct(productId);
575
-
576
- if (!product) {
577
- res.setStatusCode(404);
578
- res.render('error/notFound');
579
- return next();
580
- }
581
-
582
- // Create base product model
583
- var productModel = ProductFactory.get({
584
- product: product,
585
- variationModel: product.variationModel,
586
- options: req.querystring,
587
- promotions: null,
588
- quantity: parseInt(req.querystring.quantity, 10) || 1,
589
- variables: null,
590
- apiProduct: product,
591
- productType: product.productType
592
- });
593
-
594
- // Add custom properties
595
- productModel.customAttributes = getCustomAttributes(product);
596
- productModel.relatedProducts = getRelatedProducts(product);
597
- productModel.reviews = getProductReviews(product);
598
- productModel.availability = getStoreAvailability(product);
599
-
600
- res.render('product/productDetails', {
601
- product: productModel
602
- });
603
-
604
- next();
605
- });
606
-
607
- /**
608
- * Get custom attributes for product
609
- * @param {dw.catalog.Product} product - Product object
610
- * @returns {Object} Custom attributes
611
- */
612
- function getCustomAttributes(product) {
613
- var customAttributes = {};
614
-
615
- if (product.custom) {
616
- customAttributes.sustainabilityRating = product.custom.sustainabilityRating;
617
- customAttributes.madeIn = product.custom.madeIn;
618
- customAttributes.careInstructions = product.custom.careInstructions;
619
- }
620
-
621
- return customAttributes;
622
- }
623
-
624
- module.exports = server.exports();
625
- ```
626
-
627
- ## Advanced Model Patterns
628
-
629
- ### 1. Composite Models
630
-
631
- Combine multiple models into complex structures:
632
-
633
- ```javascript
634
- 'use strict';
635
-
636
- var CartModel = require('*/cartridge/models/cart');
637
- var AccountModel = require('*/cartridge/models/account');
638
- var AddressModel = require('*/cartridge/models/address');
639
-
640
- /**
641
- * Checkout Model - Composite model for checkout page
642
- * @param {dw.order.Basket} basket - Current basket
643
- * @param {dw.customer.Customer} customer - Current customer
644
- * @param {Object} options - Additional options
645
- * @constructor
646
- */
647
- function Checkout(basket, customer, options) {
648
- // Cart information
649
- this.cart = new CartModel(basket);
650
-
651
- // Customer information
652
- if (customer && customer.authenticated) {
653
- this.customer = new AccountModel(customer);
654
- this.addresses = getCustomerAddresses(customer);
655
- this.paymentInstruments = getCustomerPaymentInstruments(customer);
656
- } else {
657
- this.customer = null;
658
- this.addresses = [];
659
- this.paymentInstruments = [];
660
- }
661
-
662
- // Checkout-specific data
663
- this.forms = getCheckoutForms();
664
- this.shipping = getShippingOptions(basket);
665
- this.payment = getPaymentOptions();
666
- this.order = getOrderSummary(basket);
667
- }
668
-
669
- /**
670
- * Get customer addresses as models
671
- * @param {dw.customer.Customer} customer - Customer object
672
- * @returns {Array} Array of address models
673
- */
674
- function getCustomerAddresses(customer) {
675
- var addresses = [];
676
- var addressBook = customer.addressBook;
677
-
678
- if (addressBook && addressBook.addresses) {
679
- for (var i = 0; i < addressBook.addresses.length; i++) {
680
- addresses.push(new AddressModel(addressBook.addresses[i]));
681
- }
682
- }
683
-
684
- return addresses;
685
- }
686
-
687
- module.exports = Checkout;
688
- ```
689
-
690
- ### 2. Cached Models
691
-
692
- Implement caching for expensive model operations:
693
-
694
- ```javascript
695
- 'use strict';
696
-
697
- var CacheMgr = require('dw/system/CacheMgr');
698
- var ProductMgr = require('dw/catalog/ProductMgr');
699
- var Logger = require('dw/system/Logger');
700
-
701
- var cache = CacheMgr.getCache('ProductRecommendations');
702
- var logger = Logger.getLogger('models', 'ProductRecommendations');
703
-
704
- /**
705
- * Product Recommendations Model with Caching
706
- * @param {dw.catalog.Product} product - Product for recommendations
707
- * @param {number} maxRecommendations - Maximum number of recommendations
708
- * @constructor
709
- */
710
- function ProductRecommendations(product, maxRecommendations) {
711
- this.recommendations = getRecommendations(product, maxRecommendations || 4);
712
- }
713
-
714
- /**
715
- * Get product recommendations with caching
716
- * @param {dw.catalog.Product} product - Product object
717
- * @param {number} maxRecommendations - Maximum recommendations
718
- * @returns {Array} Array of recommended products
719
- */
720
- function getRecommendations(product, maxRecommendations) {
721
- var cacheKey = 'recommendations_' + product.ID + '_' + maxRecommendations;
722
- var cachedRecommendations = cache.get(cacheKey);
723
-
724
- if (cachedRecommendations) {
725
- logger.debug('Using cached recommendations for product: {0}', product.ID);
726
- return cachedRecommendations;
727
- }
728
-
729
- logger.debug('Generating new recommendations for product: {0}', product.ID);
730
-
731
- var recommendations = [];
732
- var recommendedProducts = product.getRecommendations();
733
-
734
- if (recommendedProducts) {
735
- var ProductFactory = require('*/cartridge/scripts/factories/product');
736
- var iterator = recommendedProducts.iterator();
737
-
738
- while (iterator.hasNext() && recommendations.length < maxRecommendations) {
739
- var recommendedProduct = iterator.next();
740
- if (recommendedProduct.online) {
741
- var productModel = ProductFactory.get({
742
- product: recommendedProduct,
743
- variationModel: recommendedProduct.variationModel,
744
- options: {},
745
- promotions: null,
746
- quantity: 1,
747
- variables: null,
748
- apiProduct: recommendedProduct,
749
- productType: recommendedProduct.productType
750
- });
751
-
752
- recommendations.push(productModel);
753
- }
754
- }
755
- }
756
-
757
- // Cache for 1 hour
758
- cache.put(cacheKey, recommendations, 3600);
759
-
760
- return recommendations;
761
- }
762
-
763
- module.exports = ProductRecommendations;
764
- ```
765
-
766
- ## Model Testing Strategies
767
-
768
- ### Unit Testing Models
769
-
770
- ```javascript
771
- 'use strict';
772
-
773
- var assert = require('chai').assert;
774
- var AccountModel = require('../../../cartridges/app_custom/cartridge/models/account');
775
-
776
- describe('Account Model', function() {
777
- var mockCustomer;
778
- var mockProfile;
779
- var mockAddressBook;
780
-
781
- beforeEach(function() {
782
- mockProfile = {
783
- firstName: 'John',
784
- lastName: 'Doe',
785
- email: 'john.doe@example.com',
786
- custom: {
787
- loyaltyNumber: 'LP123456',
788
- loyaltyTier: 'Gold',
789
- loyaltyPoints: 1500
790
- }
791
- };
792
-
793
- mockCustomer = {
794
- authenticated: true,
795
- profile: mockProfile
796
- };
797
-
798
- mockAddressBook = {
799
- addresses: []
800
- };
801
- });
802
-
803
- describe('Constructor', function() {
804
- it('should create account with loyalty program data', function() {
805
- var account = new AccountModel(mockCustomer, mockAddressBook, {});
806
-
807
- assert.isNotNull(account.loyaltyProgram);
808
- assert.equal(account.loyaltyProgram.number, 'LP123456');
809
- assert.equal(account.loyaltyProgram.tier, 'Gold');
810
- assert.equal(account.loyaltyProgram.points, 1500);
811
- });
812
-
813
- it('should handle customer without loyalty program', function() {
814
- delete mockCustomer.profile.custom;
815
- var account = new AccountModel(mockCustomer, mockAddressBook, {});
816
-
817
- assert.isNull(account.loyaltyProgram);
818
- });
819
- });
820
- });
821
- ```
822
-
823
- ## Performance Best Practices
824
-
825
- ### 1. Minimize API Calls
826
-
827
- ```javascript
828
- // ❌ Bad: Multiple API calls in loop
829
- function getBadProductData(productIds) {
830
- var products = [];
831
- for (var i = 0; i < productIds.length; i++) {
832
- var product = ProductMgr.getProduct(productIds[i]); // API call per product
833
- products.push(transformProduct(product));
834
- }
835
- return products;
836
- }
837
-
838
- // ✅ Good: Single API call with batch processing
839
- function getGoodProductData(productIds) {
840
- var ProductSearchModel = require('dw/catalog/ProductSearchModel');
841
- var searchModel = new ProductSearchModel();
842
- searchModel.setProductIDs(productIds);
843
- searchModel.search();
844
-
845
- var products = [];
846
- var productHits = searchModel.getProductSearchHits();
847
-
848
- while (productHits.hasNext()) {
849
- var productHit = productHits.next();
850
- products.push(transformProduct(productHit.product));
851
- }
852
-
853
- return products;
854
- }
855
- ```
856
-
857
- ### 2. Lazy Loading Properties
858
-
859
- ```javascript
860
- 'use strict';
861
-
862
- /**
863
- * Product Model with Lazy Loading
864
- */
865
- function Product(apiProduct) {
866
- this.id = apiProduct.ID;
867
- this.name = apiProduct.name;
868
-
869
- // Lazy load expensive properties
870
- Object.defineProperty(this, 'recommendations', {
871
- get: function() {
872
- if (!this._recommendations) {
873
- this._recommendations = getProductRecommendations(apiProduct);
874
- }
875
- return this._recommendations;
876
- },
877
- enumerable: true
878
- });
879
- }
880
- ```
881
-
882
- ### 3. Efficient Data Transformation
883
-
884
- ```javascript
885
- 'use strict';
886
-
887
- var collections = require('*/cartridge/scripts/util/collections');
888
-
889
- /**
890
- * Transform collection efficiently using collections.map
891
- */
892
- function transformProductLineItems(lineItems) {
893
- return collections.map(lineItems, function(lineItem) {
894
- return {
895
- productID: lineItem.productID,
896
- productName: lineItem.productName,
897
- price: lineItem.price.value,
898
- quantity: lineItem.quantity.value
899
- };
900
- });
901
- }
902
-
903
- /**
904
- * Filter and transform in single pass
905
- */
906
- function getAvailableProducts(products) {
907
- return collections.map(
908
- collections.select(products, function(product) {
909
- return product.online && product.availabilityModel.available;
910
- }),
911
- function(product) {
912
- return transformProductTile(product);
913
- }
914
- );
915
- }
916
- ```
917
-
918
- ## Security Considerations
919
-
920
- ### 1. Data Sanitization
921
-
922
- ```javascript
923
- 'use strict';
924
-
925
- var StringUtils = require('dw/util/StringUtils');
926
-
927
- /**
928
- * Sanitize user-generated content in models
929
- */
930
- function sanitizeCustomerData(customer) {
931
- return {
932
- firstName: StringUtils.encodeString(customer.profile.firstName, StringUtils.ENCODE_TYPE_HTML),
933
- lastName: StringUtils.encodeString(customer.profile.lastName, StringUtils.ENCODE_TYPE_HTML),
934
- email: customer.profile.email // Email validation handled elsewhere
935
- };
936
- }
937
-
938
- /**
939
- * Remove sensitive data from model output
940
- */
941
- function sanitizePaymentInstrument(paymentInstrument) {
942
- return {
943
- UUID: paymentInstrument.UUID,
944
- maskedCreditCardNumber: paymentInstrument.maskedCreditCardNumber,
945
- creditCardType: paymentInstrument.creditCardType,
946
- // Never expose: creditCardNumber, securityCode
947
- expirationMonth: paymentInstrument.expirationMonth,
948
- expirationYear: paymentInstrument.expirationYear
949
- };
950
- }
951
- ```
952
-
953
- ### 2. Access Control in Models
954
-
955
- ```javascript
956
- 'use strict';
957
-
958
- /**
959
- * Customer Model with Privacy Controls
960
- */
961
- function Customer(apiCustomer, viewingCustomer) {
962
- // Public information always available
963
- this.customerNumber = apiCustomer.customerNo;
964
-
965
- // Private information only for authenticated customer
966
- if (viewingCustomer && viewingCustomer.UUID === apiCustomer.UUID) {
967
- this.profile = getCustomerProfile(apiCustomer);
968
- this.addresses = getCustomerAddresses(apiCustomer);
969
- this.orders = getCustomerOrders(apiCustomer);
970
- }
971
-
972
- // Admin-only information
973
- if (viewingCustomer && hasAdminPermission(viewingCustomer)) {
974
- this.internalNotes = apiCustomer.custom.internalNotes;
975
- this.riskScore = apiCustomer.custom.riskScore;
976
- }
977
- }
978
- ```
979
-
980
- ## Model Documentation Standards
981
-
982
- ### JSDoc Documentation
983
-
984
- ```javascript
985
- 'use strict';
986
-
987
- /**
988
- * Enhanced Product Model
989
- *
990
- * @namespace ProductModel
991
- * @description Provides a comprehensive JSON representation of SFCC Product objects
992
- * with additional business logic for storefront display
993
- */
994
-
995
- /**
996
- * Create enhanced product model
997
- *
998
- * @memberof ProductModel
999
- * @param {dw.catalog.Product} apiProduct - SFCC Product API object
1000
- * @param {Object} options - Configuration options for model creation
1001
- * @param {dw.catalog.ProductVariationModel} options.variationModel - Product variation model
1002
- * @param {number} options.quantity - Selected quantity for pricing calculations
1003
- * @param {dw.util.Collection<dw.campaign.Promotion>} options.promotions - Active promotions
1004
- * @param {Object} options.variables - Additional variables from request
1005
- *
1006
- * @returns {Object} Enhanced product model with following structure:
1007
- * @returns {string} returns.id - Product ID
1008
- * @returns {string} returns.productName - Localized product name
1009
- * @returns {string} returns.productType - Type: 'master', 'variant', 'simple', 'bundle', 'set'
1010
- * @returns {Object} returns.price - Price information with sales/list prices
1011
- * @returns {Array<Object>} returns.images - Product images in various sizes
1012
- * @returns {Object} returns.availability - Availability and inventory information
1013
- * @returns {Array<Object>} returns.variationAttributes - Available variation attributes
1014
- * @returns {string} returns.longDescription - Full product description
1015
- * @returns {Object} returns.custom - Custom product attributes
1016
- *
1017
- * @throws {Error} Throws error if apiProduct is null or undefined
1018
- *
1019
- * @since 1.0.0
1020
- * @version 2.1.0 - Added sustainability attributes
1021
- */
1022
- function createEnhancedProduct(apiProduct, options) {
1023
- // Implementation here
1024
- }
1025
- ```
1026
-
1027
- ## Common Model Patterns & Anti-Patterns
1028
-
1029
- ### ✅ Good Patterns
1030
-
1031
- ```javascript
1032
- // 1. Consistent constructor pattern
1033
- function ModelName(apiObject, options) {
1034
- this.property = transformProperty(apiObject.property);
1035
- }
1036
-
1037
- // 2. Use Object.defineProperty for computed properties
1038
- Object.defineProperty(this, 'computedProperty', {
1039
- enumerable: true,
1040
- value: calculateValue()
1041
- });
1042
-
1043
- // 3. Separate transformation logic into functions
1044
- function transformPrice(apiPrice) {
1045
- return {
1046
- value: apiPrice.value,
1047
- currency: apiPrice.currencyCode,
1048
- formatted: StringUtils.formatMoney(apiPrice)
1049
- };
1050
- }
1051
-
1052
- // 4. Use factory pattern for complex models
1053
- var ProductFactory = {
1054
- get: function(options) {
1055
- return createProductModel(options);
1056
- }
1057
- };
1058
- ```
1059
-
1060
- ### ❌ Anti-Patterns to Avoid
1061
-
1062
- ```javascript
1063
- // 1. Don't put business logic in templates
1064
- // ❌ Bad: Logic in ISML template
1065
- <isif condition="${pdict.product.price.value > 100 && pdict.customer.tier === 'gold'}">
1066
- <!-- discount logic -->
1067
- </isif>
1068
-
1069
- // ✅ Good: Logic in model
1070
- function Product(apiProduct, customer) {
1071
- this.showGoldDiscount = apiProduct.price.value > 100 && customer.tier === 'gold';
1072
- }
1073
-
1074
- // 2. Don't make API calls in model getters
1075
- // ❌ Bad: API call in getter
1076
- Object.defineProperty(this, 'recommendations', {
1077
- get: function() {
1078
- return apiProduct.getRecommendations(); // Expensive API call
1079
- }
1080
- });
1081
-
1082
- // ✅ Good: Pre-compute in constructor or use caching
1083
- function Product(apiProduct) {
1084
- this.recommendations = getRecommendationsWithCache(apiProduct);
1085
- }
1086
-
1087
- // 3. Don't expose API objects directly
1088
- // ❌ Bad: Exposing API object
1089
- this.product = apiProduct; // Exposes entire API object
1090
-
1091
- // ✅ Good: Extract needed properties
1092
- this.id = apiProduct.ID;
1093
- this.name = apiProduct.name;
1094
- ```
1095
-
1096
- ## Integration with Controllers
1097
-
1098
- ### Model Usage in Controllers
1099
-
1100
- ```javascript
1101
- 'use strict';
1102
-
1103
- var server = require('server');
1104
- var BasketMgr = require('dw/order/BasketMgr');
1105
- var CartModel = require('*/cartridge/models/cart');
1106
- var AccountModel = require('*/cartridge/models/account');
1107
-
1108
- server.post('AddToCart', function (req, res, next) {
1109
- var currentBasket = BasketMgr.getCurrentBasket();
1110
- var customer = req.currentCustomer;
1111
-
1112
- // Perform cart operations
1113
- var result = addProductToCart(req.form.pid, req.form.quantity);
1114
-
1115
- if (result.success) {
1116
- // Create models for response
1117
- var cartModel = new CartModel(currentBasket);
1118
-
1119
- // Add customer-specific data if authenticated
1120
- if (customer.authenticated) {
1121
- var accountModel = new AccountModel(customer.raw);
1122
- cartModel.customer = accountModel;
1123
- }
1124
-
1125
- // Return JSON response with models
1126
- res.json({
1127
- success: true,
1128
- cart: cartModel,
1129
- message: Resource.msg('cart.add.success', 'cart', null)
1130
- });
1131
- } else {
1132
- res.json({
1133
- success: false,
1134
- error: result.error
1135
- });
1136
- }
1137
-
1138
- next();
1139
- });
1140
- ```
1141
-
1142
- This comprehensive guide covers all aspects of SFRA model development, from basic patterns to advanced techniques. Use the SFRA documentation tools available through this MCP server to explore existing models and understand their implementations before creating your own customizations.