@salesforce/b2c-cli 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dev.js +8 -8
- package/bin/run.js +5 -7
- package/content/guidance/b2c/b2c-business-manager-extensions/SKILL.md +361 -0
- package/content/guidance/b2c/b2c-business-manager-extensions/references/EXTENSIONS-XML.md +458 -0
- package/content/guidance/b2c/b2c-controllers/SKILL.md +301 -0
- package/content/guidance/b2c/b2c-controllers/references/CLASSIC-PATTERNS.md +335 -0
- package/content/guidance/b2c/b2c-controllers/references/SFRA-PATTERNS.md +400 -0
- package/content/guidance/b2c/b2c-custom-api-development/SKILL.md +281 -0
- package/content/guidance/b2c/b2c-custom-api-development/references/CONTRACT.md +142 -0
- package/content/guidance/b2c/b2c-custom-api-development/references/IMPLEMENTATION.md +153 -0
- package/content/guidance/b2c/b2c-custom-api-development/references/TESTING.md +118 -0
- package/content/guidance/b2c/b2c-custom-caches/SKILL.md +279 -0
- package/content/guidance/b2c/b2c-custom-job-steps/SKILL.md +520 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/CHUNK-ORIENTED.md +377 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/JOBS-XML.md +212 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/STEPTYPES-JSON.md +373 -0
- package/content/guidance/b2c/b2c-custom-job-steps/references/TASK-ORIENTED.md +344 -0
- package/content/guidance/b2c/b2c-custom-objects/SKILL.md +327 -0
- package/content/guidance/b2c/b2c-custom-objects/references/OCAPI-SEARCH.md +298 -0
- package/content/guidance/b2c/b2c-forms/SKILL.md +242 -0
- package/content/guidance/b2c/b2c-forms/references/FORM-XML.md +409 -0
- package/content/guidance/b2c/b2c-hooks/SKILL.md +500 -0
- package/content/guidance/b2c/b2c-hooks/references/OCAPI-SCAPI-HOOKS.md +403 -0
- package/content/guidance/b2c/b2c-hooks/references/ORDER-HOOK-LIFECYCLE.md +169 -0
- package/content/guidance/b2c/b2c-hooks/references/SYSTEM-HOOKS.md +433 -0
- package/content/guidance/b2c/b2c-isml/SKILL.md +320 -0
- package/content/guidance/b2c/b2c-isml/references/EXPRESSIONS.md +366 -0
- package/content/guidance/b2c/b2c-isml/references/TAGS.md +443 -0
- package/content/guidance/b2c/b2c-localization/SKILL.md +344 -0
- package/content/guidance/b2c/b2c-localization/references/PATTERNS.md +407 -0
- package/content/guidance/b2c/b2c-logging/SKILL.md +352 -0
- package/content/guidance/b2c/b2c-logging/references/LOG-FILES.md +282 -0
- package/content/guidance/b2c/b2c-metadata/SKILL.md +406 -0
- package/content/guidance/b2c/b2c-metadata/references/SYSTEM-OBJECTS.md +320 -0
- package/content/guidance/b2c/b2c-metadata/references/XML-EXAMPLES.md +366 -0
- package/content/guidance/b2c/b2c-onboarding/SKILL.md +154 -0
- package/content/guidance/b2c/b2c-ordering/SKILL.md +391 -0
- package/content/guidance/b2c/b2c-page-designer/SKILL.md +410 -0
- package/content/guidance/b2c/b2c-page-designer/references/ATTRIBUTE-TYPES.md +436 -0
- package/content/guidance/b2c/b2c-page-designer/references/META-DEFINITIONS.md +340 -0
- package/content/guidance/b2c/b2c-querying-data/SKILL.md +289 -0
- package/content/guidance/b2c/b2c-querying-data/references/PERFORMANCE-APIS.md +74 -0
- package/content/guidance/b2c/b2c-scapi-admin/SKILL.md +53 -0
- package/content/guidance/b2c/b2c-scapi-admin/references/CLIENT-EXAMPLES.md +440 -0
- package/content/guidance/b2c/b2c-scapi-admin/references/INTEGRATION-PATTERNS.md +518 -0
- package/content/guidance/b2c/b2c-scapi-admin/references/OAUTH-SCOPES.md +337 -0
- package/content/guidance/b2c/b2c-scapi-shopper/SKILL.md +56 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/CHECKOUT-FLOW.md +466 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/CLIENT-EXAMPLES.md +351 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/COMMON-PATTERNS.md +390 -0
- package/content/guidance/b2c/b2c-scapi-shopper/references/SCOPES.md +290 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/SKILL.md +420 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/references/PASSKEYS.md +126 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/references/SESSION-BRIDGE.md +267 -0
- package/content/guidance/b2c/b2c-slas-auth-patterns/references/TOKEN-LIFECYCLE.md +367 -0
- package/content/guidance/b2c/b2c-webservices/SKILL.md +318 -0
- package/content/guidance/b2c/b2c-webservices/references/FTP-SERVICES.md +524 -0
- package/content/guidance/b2c/b2c-webservices/references/HTTP-SERVICES.md +578 -0
- package/content/guidance/b2c/b2c-webservices/references/SERVICES-XML.md +351 -0
- package/content/guidance/b2c/b2c-webservices/references/SOAP-SERVICES.md +587 -0
- package/content/guidance/b2c-cli/b2c-am/SKILL.md +277 -0
- package/content/guidance/b2c-cli/b2c-bm-users-roles/SKILL.md +210 -0
- package/content/guidance/b2c-cli/b2c-cap/SKILL.md +131 -0
- package/content/guidance/b2c-cli/b2c-cip/SKILL.md +116 -0
- package/content/guidance/b2c-cli/b2c-cip/references/KNOWN_TABLES.md +105 -0
- package/content/guidance/b2c-cli/b2c-cip/references/SALES_ANALYSIS.md +50 -0
- package/content/guidance/b2c-cli/b2c-cip/references/STARTER_QUERIES.md +147 -0
- package/content/guidance/b2c-cli/b2c-code/SKILL.md +146 -0
- package/content/guidance/b2c-cli/b2c-config/SKILL.md +462 -0
- package/content/guidance/b2c-cli/b2c-content/SKILL.md +176 -0
- package/content/guidance/b2c-cli/b2c-debug/SKILL.md +138 -0
- package/content/guidance/b2c-cli/b2c-docs/SKILL.md +301 -0
- package/content/guidance/b2c-cli/b2c-ecdn/SKILL.md +135 -0
- package/content/guidance/b2c-cli/b2c-ecdn/references/ADVANCED.md +97 -0
- package/content/guidance/b2c-cli/b2c-ecdn/references/SECURITY.md +75 -0
- package/content/guidance/b2c-cli/b2c-import-set-migrations/SKILL.md +265 -0
- package/content/guidance/b2c-cli/b2c-job/SKILL.md +64 -0
- package/content/guidance/b2c-cli/b2c-job/references/EXPORT.md +121 -0
- package/content/guidance/b2c-cli/b2c-job/references/IMPORT.md +55 -0
- package/content/guidance/b2c-cli/b2c-job/references/RUN-AND-MONITOR.md +119 -0
- package/content/guidance/b2c-cli/b2c-logs/SKILL.md +249 -0
- package/content/guidance/b2c-cli/b2c-metrics/SKILL.md +315 -0
- package/content/guidance/b2c-cli/b2c-mrt/SKILL.md +207 -0
- package/content/guidance/b2c-cli/b2c-mrt/references/BUNDLE-COMMANDS.md +203 -0
- package/content/guidance/b2c-cli/b2c-mrt/references/ENVIRONMENT-COMMANDS.md +218 -0
- package/content/guidance/b2c-cli/b2c-mrt/references/PROJECT-COMMANDS.md +154 -0
- package/content/guidance/b2c-cli/b2c-sandbox/SKILL.md +112 -0
- package/content/guidance/b2c-cli/b2c-scapi-custom/SKILL.md +126 -0
- package/content/guidance/b2c-cli/b2c-scapi-schemas/SKILL.md +66 -0
- package/content/guidance/b2c-cli/b2c-scapi-schemas/references/CLI-EXAMPLES.md +108 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/SKILL.md +57 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/references/IMPORT-OPTIONS.md +118 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/references/METADATA-XML.md +381 -0
- package/content/guidance/b2c-cli/b2c-site-import-export/references/WORKFLOWS.md +182 -0
- package/content/guidance/b2c-cli/b2c-sites/SKILL.md +112 -0
- package/content/guidance/b2c-cli/b2c-slas/SKILL.md +182 -0
- package/content/guidance/b2c-cli/b2c-webdav/SKILL.md +186 -0
- package/content/guidance/b2c-ops/b2c-checkout-triage/SKILL.md +68 -0
- package/content/guidance/b2c-ops/b2c-job-health/SKILL.md +75 -0
- package/content/guidance/b2c-ops/b2c-job-health/references/job-logs.md +21 -0
- package/content/guidance/b2c-ops/b2c-order-failure-triage/SKILL.md +66 -0
- package/content/guidance/b2c-ops/b2c-order-failure-triage/references/order-evidence.md +87 -0
- package/content/guidance/b2c-ops/b2c-production-triage/SKILL.md +87 -0
- package/content/guidance/b2c-ops/b2c-production-triage/references/escalation.md +57 -0
- package/content/guidance/index.json +1949 -0
- package/content/guidance/storefront-next/sfnext-accessibility/SKILL.md +103 -0
- package/content/guidance/storefront-next/sfnext-accessibility/references/checklist.md +64 -0
- package/content/guidance/storefront-next/sfnext-analytics-consent/SKILL.md +91 -0
- package/content/guidance/storefront-next/sfnext-analytics-consent/references/CUSTOM-ADAPTER.md +49 -0
- package/content/guidance/storefront-next/sfnext-authentication/SKILL.md +127 -0
- package/content/guidance/storefront-next/sfnext-authentication/references/COOKIES.md +39 -0
- package/content/guidance/storefront-next/sfnext-authentication/references/LOGIN-FLOWS.md +59 -0
- package/content/guidance/storefront-next/sfnext-commerce-features/SKILL.md +67 -0
- package/content/guidance/storefront-next/sfnext-commerce-features/references/FEATURE-PREREQUISITES.md +37 -0
- package/content/guidance/storefront-next/sfnext-components/SKILL.md +153 -0
- package/content/guidance/storefront-next/sfnext-components/references/COMPONENT-AUTHORING.md +118 -0
- package/content/guidance/storefront-next/sfnext-components/references/SHAPE-TOKENS.md +51 -0
- package/content/guidance/storefront-next/sfnext-components/references/STORYBOOK.md +54 -0
- package/content/guidance/storefront-next/sfnext-components/references/TOKEN-SYSTEM.md +53 -0
- package/content/guidance/storefront-next/sfnext-components/references/TROUBLESHOOTING.md +19 -0
- package/content/guidance/storefront-next/sfnext-configuration/SKILL.md +163 -0
- package/content/guidance/storefront-next/sfnext-configuration/references/ENV-VARIABLES.md +55 -0
- package/content/guidance/storefront-next/sfnext-configuration/references/MULTI-SITE-URLS.md +137 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/SKILL.md +140 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/ACTIONS.md +53 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/API-CLIENTS.md +34 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/LOADERS.md +73 -0
- package/content/guidance/storefront-next/sfnext-data-fetching/references/SCAPI-FETCHER.md +39 -0
- package/content/guidance/storefront-next/sfnext-deployment/SKILL.md +127 -0
- package/content/guidance/storefront-next/sfnext-deployment/references/MRT-DEPLOYMENT.md +59 -0
- package/content/guidance/storefront-next/sfnext-extensions/SKILL.md +118 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/ACTION-HOOKS.md +57 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/BASE-AUDIT.md +68 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/CLI-AND-INSTALL.md +58 -0
- package/content/guidance/storefront-next/sfnext-extensions/references/EXTENSION-EXAMPLES.md +79 -0
- package/content/guidance/storefront-next/sfnext-hybrid-storefronts/SKILL.md +93 -0
- package/content/guidance/storefront-next/sfnext-hybrid-storefronts/references/HYBRID-PROXY-CONFIG.md +86 -0
- package/content/guidance/storefront-next/sfnext-i18n/SKILL.md +152 -0
- package/content/guidance/storefront-next/sfnext-i18n/references/locale-config.md +35 -0
- package/content/guidance/storefront-next/sfnext-overview/SKILL.md +101 -0
- package/content/guidance/storefront-next/sfnext-page-designer/SKILL.md +202 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/BUSINESS-MANAGER.md +46 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/COMPONENT-REGISTRY.md +111 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/DECORATOR-PATTERNS.md +168 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/REVIEW-CHECKLIST.md +83 -0
- package/content/guidance/storefront-next/sfnext-page-designer/references/TROUBLESHOOTING.md +35 -0
- package/content/guidance/storefront-next/sfnext-performance/SKILL.md +102 -0
- package/content/guidance/storefront-next/sfnext-performance/references/PERFORMANCE-REVIEW-CHECKLIST.md +85 -0
- package/content/guidance/storefront-next/sfnext-performance/references/SUSPENSE-AND-STREAMING.md +58 -0
- package/content/guidance/storefront-next/sfnext-project-setup/SKILL.md +147 -0
- package/content/guidance/storefront-next/sfnext-project-setup/references/PROJECT-STRUCTURE.md +61 -0
- package/content/guidance/storefront-next/sfnext-project-setup/references/SCRIPTS.md +47 -0
- package/content/guidance/storefront-next/sfnext-project-setup/references/SFNEXT-CLI.md +63 -0
- package/content/guidance/storefront-next/sfnext-quality-gates/SKILL.md +70 -0
- package/content/guidance/storefront-next/sfnext-quality-gates/references/lint-and-budgets.md +39 -0
- package/content/guidance/storefront-next/sfnext-revalidation/SKILL.md +121 -0
- package/content/guidance/storefront-next/sfnext-revalidation/references/POLICIES-AND-TAGS.md +55 -0
- package/content/guidance/storefront-next/sfnext-routing/SKILL.md +123 -0
- package/content/guidance/storefront-next/sfnext-routing/references/ROUTE-CONVENTIONS.md +65 -0
- package/content/guidance/storefront-next/sfnext-routing/references/URLS-AND-SEO-ROUTES.md +22 -0
- package/content/guidance/storefront-next/sfnext-scapi/SKILL.md +126 -0
- package/content/guidance/storefront-next/sfnext-scapi/references/WORKED-EXAMPLE.md +39 -0
- package/content/guidance/storefront-next/sfnext-security/SKILL.md +129 -0
- package/content/guidance/storefront-next/sfnext-security/references/COOKIE-DOMAIN.md +39 -0
- package/content/guidance/storefront-next/sfnext-security/references/TURNSTILE.md +43 -0
- package/content/guidance/storefront-next/sfnext-seo/SKILL.md +95 -0
- package/content/guidance/storefront-next/sfnext-seo/references/MULTI-DOMAIN-BASE-PATH.md +17 -0
- package/content/guidance/storefront-next/sfnext-seo/references/SEO-ROUTES.md +31 -0
- package/content/guidance/storefront-next/sfnext-state-management/SKILL.md +114 -0
- package/content/guidance/storefront-next/sfnext-state-management/references/PATTERNS.md +45 -0
- package/content/guidance/storefront-next/sfnext-testing/SKILL.md +151 -0
- package/content/guidance/storefront-next/sfnext-testing/references/E2E.md +38 -0
- package/content/guidance/storefront-next/sfnext-testing/references/STORYBOOK-PATTERNS.md +97 -0
- package/content/guidance/storefront-next/sfnext-testing/references/UNIT-AND-ROUTE-TESTS.md +60 -0
- package/content/guidance/storefront-next/sfnext-theming/SKILL.md +104 -0
- package/content/guidance/storefront-next/sfnext-theming/references/REBRAND-CHECKLIST.md +29 -0
- package/dist/commands/cap/install.d.ts +1 -0
- package/dist/commands/cap/list.d.ts +1 -0
- package/dist/commands/cap/pull.d.ts +1 -0
- package/dist/commands/cap/tasks.d.ts +1 -0
- package/dist/commands/cap/uninstall.d.ts +1 -0
- package/dist/commands/cip/describe.d.ts +1 -0
- package/dist/commands/cip/query.d.ts +1 -0
- package/dist/commands/cip/report/bot-traffic-share.d.ts +1 -0
- package/dist/commands/cip/report/checkout-funnel-dropoff.d.ts +1 -0
- package/dist/commands/cip/report/controller-error-rate-trend.d.ts +1 -0
- package/dist/commands/cip/report/controller-health-scorecard.d.ts +1 -0
- package/dist/commands/cip/report/customer-registration-trends.d.ts +1 -0
- package/dist/commands/cip/report/discount-depth-breakdown.d.ts +1 -0
- package/dist/commands/cip/report/inventory-stockout-by-location.d.ts +1 -0
- package/dist/commands/cip/report/new-vs-returning-buyer-revenue.d.ts +1 -0
- package/dist/commands/cip/report/ocapi-client-usage.d.ts +1 -0
- package/dist/commands/cip/report/ocapi-requests.d.ts +1 -0
- package/dist/commands/cip/report/payment-method-performance.d.ts +1 -0
- package/dist/commands/cip/report/product-co-purchase-analysis.d.ts +1 -0
- package/dist/commands/cip/report/promotion-discount-analysis.d.ts +1 -0
- package/dist/commands/cip/report/promotion-roi-leaderboard.d.ts +1 -0
- package/dist/commands/cip/report/recommender-effectiveness.d.ts +1 -0
- package/dist/commands/cip/report/remote-include-performance.d.ts +1 -0
- package/dist/commands/cip/report/revenue-by-channel.d.ts +1 -0
- package/dist/commands/cip/report/sales-analytics.d.ts +1 -0
- package/dist/commands/cip/report/sales-summary.d.ts +1 -0
- package/dist/commands/cip/report/scapi-cache-hit-ratio.d.ts +1 -0
- package/dist/commands/cip/report/scapi-error-rate-by-status.d.ts +1 -0
- package/dist/commands/cip/report/scapi-latency-distribution.d.ts +1 -0
- package/dist/commands/cip/report/scapi-traffic-latency.d.ts +1 -0
- package/dist/commands/cip/report/search-query-performance.d.ts +1 -0
- package/dist/commands/cip/report/top-referrers.d.ts +1 -0
- package/dist/commands/cip/report/top-selling-products.d.ts +1 -0
- package/dist/commands/cip/report/zero-result-searches.d.ts +1 -0
- package/dist/commands/cip/tables.d.ts +1 -0
- package/dist/commands/code/activate.d.ts +1 -0
- package/dist/commands/code/delete.d.ts +1 -0
- package/dist/commands/code/deploy.d.ts +1 -0
- package/dist/commands/code/download.d.ts +1 -0
- package/dist/commands/code/watch.d.ts +1 -0
- package/dist/commands/commands/search.d.ts +35 -0
- package/dist/commands/commands/search.js +85 -0
- package/dist/commands/commands/search.js.map +1 -0
- package/dist/commands/content/export.d.ts +1 -0
- package/dist/commands/content/list.d.ts +1 -0
- package/dist/commands/content/validate.d.ts +1 -0
- package/dist/commands/debug/cli.d.ts +1 -0
- package/dist/commands/debug/index.d.ts +1 -0
- package/dist/commands/docs/cache.d.ts +1 -0
- package/dist/commands/docs/download.d.ts +1 -0
- package/dist/commands/docs/read.d.ts +1 -0
- package/dist/commands/docs/schema.d.ts +1 -0
- package/dist/commands/docs/search.d.ts +1 -0
- package/dist/commands/docs/skill.d.ts +41 -0
- package/dist/commands/docs/skill.js +183 -0
- package/dist/commands/docs/skill.js.map +1 -0
- package/dist/commands/ecdn/cache/purge.d.ts +1 -0
- package/dist/commands/ecdn/certificates/add.d.ts +1 -0
- package/dist/commands/ecdn/certificates/delete.d.ts +1 -0
- package/dist/commands/ecdn/certificates/list.d.ts +1 -0
- package/dist/commands/ecdn/certificates/update.d.ts +1 -0
- package/dist/commands/ecdn/certificates/validate.d.ts +1 -0
- package/dist/commands/ecdn/cipher-suites/get.d.ts +1 -0
- package/dist/commands/ecdn/cipher-suites/update.d.ts +1 -0
- package/dist/commands/ecdn/firewall/create.d.ts +1 -0
- package/dist/commands/ecdn/firewall/delete.d.ts +1 -0
- package/dist/commands/ecdn/firewall/get.d.ts +1 -0
- package/dist/commands/ecdn/firewall/list.d.ts +1 -0
- package/dist/commands/ecdn/firewall/reorder.d.ts +1 -0
- package/dist/commands/ecdn/firewall/update.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/create.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/delete.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/get.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/list.d.ts +1 -0
- package/dist/commands/ecdn/logpush/jobs/update.d.ts +1 -0
- package/dist/commands/ecdn/logpush/ownership.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/create.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/delete.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/get.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/rules/delete.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/rules/update.d.ts +1 -0
- package/dist/commands/ecdn/mrt-rules/update.d.ts +1 -0
- package/dist/commands/ecdn/mtls/create.d.ts +1 -0
- package/dist/commands/ecdn/mtls/delete.d.ts +1 -0
- package/dist/commands/ecdn/mtls/get.d.ts +1 -0
- package/dist/commands/ecdn/mtls/issue.d.ts +1 -0
- package/dist/commands/ecdn/mtls/list.d.ts +1 -0
- package/dist/commands/ecdn/mtls/setup.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/delete.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/get.d.ts +1 -0
- package/dist/commands/ecdn/origin-headers/set.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/create.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/delete.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/notifications/list.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/create.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/delete.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/get.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/list.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/policies/update.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/scripts/get.d.ts +1 -0
- package/dist/commands/ecdn/page-shield/scripts/list.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/create.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/delete.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/get.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/list.d.ts +1 -0
- package/dist/commands/ecdn/rate-limit/update.d.ts +1 -0
- package/dist/commands/ecdn/security/get.d.ts +1 -0
- package/dist/commands/ecdn/security/update.d.ts +1 -0
- package/dist/commands/ecdn/speed/get.d.ts +1 -0
- package/dist/commands/ecdn/speed/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/groups/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/groups/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/managed-rules/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/managed-rules/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/migrate.d.ts +1 -0
- package/dist/commands/ecdn/waf/owasp/get.d.ts +1 -0
- package/dist/commands/ecdn/waf/owasp/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/get.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/rules/update.d.ts +1 -0
- package/dist/commands/ecdn/waf/rulesets/list.d.ts +1 -0
- package/dist/commands/ecdn/waf/rulesets/update.d.ts +1 -0
- package/dist/commands/ecdn/zones/create.d.ts +1 -0
- package/dist/commands/ecdn/zones/list.d.ts +1 -0
- package/dist/commands/job/execution/delete.d.ts +1 -0
- package/dist/commands/job/export.d.ts +1 -0
- package/dist/commands/job/import-set.d.ts +1 -0
- package/dist/commands/job/import.d.ts +1 -0
- package/dist/commands/job/log.d.ts +1 -0
- package/dist/commands/job/run.d.ts +1 -0
- package/dist/commands/job/search.d.ts +1 -0
- package/dist/commands/job/wait.d.ts +1 -0
- package/dist/commands/logs/get.d.ts +1 -0
- package/dist/commands/logs/list.d.ts +1 -0
- package/dist/commands/logs/tail.d.ts +1 -0
- package/dist/commands/metrics/controller.d.ts +1 -0
- package/dist/commands/metrics/ecdn.d.ts +1 -0
- package/dist/commands/metrics/mrt.d.ts +1 -0
- package/dist/commands/metrics/ocapi.d.ts +1 -0
- package/dist/commands/metrics/overall.d.ts +1 -0
- package/dist/commands/metrics/sales.d.ts +1 -0
- package/dist/commands/metrics/scapi-hooks.d.ts +1 -0
- package/dist/commands/metrics/scapi.d.ts +1 -0
- package/dist/commands/metrics/third-party.d.ts +1 -0
- package/dist/commands/mrt/bundle/delete.d.ts +1 -0
- package/dist/commands/mrt/bundle/deploy.d.ts +1 -0
- package/dist/commands/mrt/bundle/download.d.ts +1 -0
- package/dist/commands/mrt/bundle/history.d.ts +1 -0
- package/dist/commands/mrt/bundle/list.d.ts +1 -0
- package/dist/commands/mrt/bundle/save.d.ts +1 -0
- package/dist/commands/mrt/bundle/upload-v2.d.ts +1 -0
- package/dist/commands/mrt/env/access-control/list.d.ts +1 -0
- package/dist/commands/mrt/env/b2c.d.ts +1 -0
- package/dist/commands/mrt/env/clone.d.ts +1 -0
- package/dist/commands/mrt/env/create.d.ts +1 -0
- package/dist/commands/mrt/env/delete.d.ts +1 -0
- package/dist/commands/mrt/env/get.d.ts +1 -0
- package/dist/commands/mrt/env/invalidate.d.ts +1 -0
- package/dist/commands/mrt/env/list.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/clone.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/create.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/delete.d.ts +1 -0
- package/dist/commands/mrt/env/redirect/list.d.ts +1 -0
- package/dist/commands/mrt/env/update.d.ts +1 -0
- package/dist/commands/mrt/env/var/delete.d.ts +1 -0
- package/dist/commands/mrt/env/var/list.d.ts +1 -0
- package/dist/commands/mrt/env/var/push.d.ts +1 -0
- package/dist/commands/mrt/env/var/set.d.ts +1 -0
- package/dist/commands/mrt/org/b2c.d.ts +1 -0
- package/dist/commands/mrt/org/cert/create.d.ts +1 -0
- package/dist/commands/mrt/org/cert/delete.d.ts +1 -0
- package/dist/commands/mrt/org/cert/get.d.ts +1 -0
- package/dist/commands/mrt/org/cert/list.d.ts +1 -0
- package/dist/commands/mrt/org/cert/restart-validation.d.ts +1 -0
- package/dist/commands/mrt/org/list.d.ts +1 -0
- package/dist/commands/mrt/org/member/add.d.ts +1 -0
- package/dist/commands/mrt/org/member/get.d.ts +1 -0
- package/dist/commands/mrt/org/member/list.d.ts +1 -0
- package/dist/commands/mrt/org/member/remove.d.ts +1 -0
- package/dist/commands/mrt/org/member/update.d.ts +1 -0
- package/dist/commands/mrt/project/create.d.ts +1 -0
- package/dist/commands/mrt/project/delete.d.ts +1 -0
- package/dist/commands/mrt/project/get.d.ts +1 -0
- package/dist/commands/mrt/project/list.d.ts +1 -0
- package/dist/commands/mrt/project/member/add.d.ts +1 -0
- package/dist/commands/mrt/project/member/get.d.ts +1 -0
- package/dist/commands/mrt/project/member/list.d.ts +1 -0
- package/dist/commands/mrt/project/member/remove.d.ts +1 -0
- package/dist/commands/mrt/project/member/update.d.ts +1 -0
- package/dist/commands/mrt/project/notification/delete.d.ts +1 -0
- package/dist/commands/mrt/project/notification/get.d.ts +1 -0
- package/dist/commands/mrt/project/update.d.ts +1 -0
- package/dist/commands/mrt/save-credentials.d.ts +1 -0
- package/dist/commands/mrt/tail-logs.d.ts +1 -0
- package/dist/commands/mrt/user/api-key.d.ts +1 -0
- package/dist/commands/mrt/user/email-prefs.d.ts +1 -0
- package/dist/commands/mrt/user/profile.d.ts +1 -0
- package/dist/commands/scaffold/init.js +2 -1
- package/dist/commands/scaffold/init.js.map +1 -1
- package/dist/commands/scapi/custom/status.d.ts +1 -0
- package/dist/commands/scapi/schemas/get.d.ts +1 -0
- package/dist/commands/scapi/schemas/list.d.ts +1 -0
- package/dist/commands/setup/ide/tsserver-plugin.d.ts +1 -0
- package/dist/commands/setup/ide/vscode-types.d.ts +1 -0
- package/dist/commands/setup/index.js +4 -3
- package/dist/commands/setup/index.js.map +1 -1
- package/dist/commands/setup/inspect.d.ts +1 -0
- package/dist/commands/setup/inspect.js +17 -2
- package/dist/commands/setup/inspect.js.map +1 -1
- package/dist/commands/setup/instance/create.d.ts +1 -0
- package/dist/commands/setup/instance/list.d.ts +1 -0
- package/dist/commands/setup/instance/remove.d.ts +1 -0
- package/dist/commands/setup/instance/set-active.d.ts +1 -0
- package/dist/commands/setup/openshell.d.ts +1 -0
- package/dist/commands/setup/skills.d.ts +1 -0
- package/dist/commands/slas/client/create.d.ts +1 -0
- package/dist/commands/slas/client/delete.d.ts +1 -0
- package/dist/commands/slas/client/get.d.ts +1 -0
- package/dist/commands/slas/client/list.d.ts +1 -0
- package/dist/commands/slas/client/open.d.ts +1 -0
- package/dist/commands/slas/client/update.d.ts +1 -0
- package/dist/commands/slas/token.d.ts +1 -0
- package/dist/commands/slas/token.js +2 -1
- package/dist/commands/slas/token.js.map +1 -1
- package/dist/commands/webdav/get.d.ts +1 -0
- package/dist/commands/webdav/rm.d.ts +1 -0
- package/dist/help.d.ts +25 -0
- package/dist/help.js +96 -0
- package/dist/help.js.map +1 -0
- package/dist/lib/scaffold/generate-helper.js +3 -2
- package/dist/lib/scaffold/generate-helper.js.map +1 -1
- package/dist/lib/skills.d.ts +19 -0
- package/dist/lib/skills.js +75 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/utils/cip/command.d.ts +1 -0
- package/dist/utils/ecdn/zone-command.d.ts +1 -0
- package/dist/utils/slas/client.d.ts +1 -0
- package/oclif.manifest.json +21814 -18473
- package/package.json +11 -5
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
# HTTP Services Reference
|
|
2
|
+
|
|
3
|
+
Patterns for implementing HTTP and REST API integrations.
|
|
4
|
+
|
|
5
|
+
## HTTPService Methods
|
|
6
|
+
|
|
7
|
+
| Method | Description |
|
|
8
|
+
|--------|-------------|
|
|
9
|
+
| `setRequestMethod(method)` | Set HTTP method (GET, POST, PUT, DELETE, PATCH) |
|
|
10
|
+
| `addHeader(name, value)` | Add request header |
|
|
11
|
+
| `addParam(name, value)` | Add URL query parameter |
|
|
12
|
+
| `setURL(url)` | Override the service URL |
|
|
13
|
+
| `setAuthentication(type)` | Set auth type ("BASIC" or "NONE") |
|
|
14
|
+
| `setEncoding(encoding)` | Set request body encoding (default: UTF-8) |
|
|
15
|
+
| `setOutFile(file)` | Write response to file |
|
|
16
|
+
| `setCachingTTL(seconds)` | Enable response caching |
|
|
17
|
+
| `setIdentity(keyRef)` | Set mTLS client certificate |
|
|
18
|
+
| `setHostNameVerification(bool)` | Enable/disable hostname verification |
|
|
19
|
+
|
|
20
|
+
## HTTPClient Properties (in parseResponse)
|
|
21
|
+
|
|
22
|
+
The `client` parameter in `parseResponse` is an `HTTPClient`:
|
|
23
|
+
|
|
24
|
+
| Property | Description |
|
|
25
|
+
|----------|-------------|
|
|
26
|
+
| `text` | Response body as string |
|
|
27
|
+
| `statusCode` | HTTP status code |
|
|
28
|
+
| `statusMessage` | HTTP status message |
|
|
29
|
+
| `responseHeaders` | Response headers |
|
|
30
|
+
| `errorText` | Error response body |
|
|
31
|
+
|
|
32
|
+
## REST API Examples
|
|
33
|
+
|
|
34
|
+
### GET Request
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
var LocalServiceRegistry = require('dw/svc/LocalServiceRegistry');
|
|
38
|
+
|
|
39
|
+
var productService = LocalServiceRegistry.createService('my.product.api', {
|
|
40
|
+
createRequest: function (svc, productId) {
|
|
41
|
+
svc.setRequestMethod('GET');
|
|
42
|
+
svc.addHeader('Accept', 'application/json');
|
|
43
|
+
svc.setURL(svc.URL + '/products/' + productId);
|
|
44
|
+
return null; // GET has no body
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
parseResponse: function (svc, client) {
|
|
48
|
+
if (client.statusCode === 200) {
|
|
49
|
+
return JSON.parse(client.text);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
filterLogMessage: function (msg) {
|
|
55
|
+
return msg;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Usage
|
|
60
|
+
var result = productService.call('SKU123');
|
|
61
|
+
if (result.ok) {
|
|
62
|
+
var product = result.object;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### POST with JSON Body
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
var orderService = LocalServiceRegistry.createService('my.order.api', {
|
|
70
|
+
createRequest: function (svc, orderData) {
|
|
71
|
+
svc.setRequestMethod('POST');
|
|
72
|
+
svc.addHeader('Content-Type', 'application/json');
|
|
73
|
+
svc.addHeader('Accept', 'application/json');
|
|
74
|
+
return JSON.stringify(orderData);
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
parseResponse: function (svc, client) {
|
|
78
|
+
var response = {
|
|
79
|
+
statusCode: client.statusCode,
|
|
80
|
+
success: client.statusCode >= 200 && client.statusCode < 300
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (response.success) {
|
|
84
|
+
response.data = JSON.parse(client.text);
|
|
85
|
+
} else {
|
|
86
|
+
response.error = client.errorText || client.text;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return response;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
filterLogMessage: function (msg) {
|
|
93
|
+
// Filter credit card numbers
|
|
94
|
+
msg = msg.replace(/\b\d{13,16}\b/g, '****');
|
|
95
|
+
return msg;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Usage
|
|
100
|
+
var result = orderService.call({
|
|
101
|
+
orderNumber: 'ORD123',
|
|
102
|
+
items: [{ sku: 'PROD1', qty: 2 }]
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### PUT Request
|
|
107
|
+
|
|
108
|
+
```javascript
|
|
109
|
+
var updateService = LocalServiceRegistry.createService('my.update.api', {
|
|
110
|
+
createRequest: function (svc, params) {
|
|
111
|
+
svc.setRequestMethod('PUT');
|
|
112
|
+
svc.addHeader('Content-Type', 'application/json');
|
|
113
|
+
svc.setURL(svc.URL + '/items/' + params.id);
|
|
114
|
+
return JSON.stringify(params.data);
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
parseResponse: function (svc, client) {
|
|
118
|
+
return {
|
|
119
|
+
success: client.statusCode === 200,
|
|
120
|
+
data: client.statusCode === 200 ? JSON.parse(client.text) : null
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
filterLogMessage: function (msg) {
|
|
125
|
+
return msg;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### DELETE Request
|
|
131
|
+
|
|
132
|
+
```javascript
|
|
133
|
+
var deleteService = LocalServiceRegistry.createService('my.delete.api', {
|
|
134
|
+
createRequest: function (svc, resourceId) {
|
|
135
|
+
svc.setRequestMethod('DELETE');
|
|
136
|
+
svc.setURL(svc.URL + '/resources/' + resourceId);
|
|
137
|
+
return null;
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
parseResponse: function (svc, client) {
|
|
141
|
+
return {
|
|
142
|
+
success: client.statusCode === 204 || client.statusCode === 200
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
|
|
146
|
+
filterLogMessage: function (msg) {
|
|
147
|
+
return msg;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### GET with Query Parameters
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
var searchService = LocalServiceRegistry.createService('my.search.api', {
|
|
156
|
+
createRequest: function (svc, params) {
|
|
157
|
+
svc.setRequestMethod('GET');
|
|
158
|
+
svc.addHeader('Accept', 'application/json');
|
|
159
|
+
|
|
160
|
+
// Add query parameters
|
|
161
|
+
if (params.query) {
|
|
162
|
+
svc.addParam('q', params.query);
|
|
163
|
+
}
|
|
164
|
+
if (params.limit) {
|
|
165
|
+
svc.addParam('limit', params.limit.toString());
|
|
166
|
+
}
|
|
167
|
+
if (params.offset) {
|
|
168
|
+
svc.addParam('offset', params.offset.toString());
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return null;
|
|
172
|
+
},
|
|
173
|
+
|
|
174
|
+
parseResponse: function (svc, client) {
|
|
175
|
+
return JSON.parse(client.text);
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
filterLogMessage: function (msg) {
|
|
179
|
+
return msg;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Usage: /search?q=shoes&limit=10&offset=0
|
|
184
|
+
var result = searchService.call({
|
|
185
|
+
query: 'shoes',
|
|
186
|
+
limit: 10,
|
|
187
|
+
offset: 0
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Authentication Patterns
|
|
192
|
+
|
|
193
|
+
### Basic Authentication
|
|
194
|
+
|
|
195
|
+
Basic auth uses credentials from Business Manager:
|
|
196
|
+
|
|
197
|
+
```javascript
|
|
198
|
+
var basicAuthService = LocalServiceRegistry.createService('my.basic.auth.api', {
|
|
199
|
+
createRequest: function (svc, params) {
|
|
200
|
+
// Authentication is automatic if credential has user/password
|
|
201
|
+
svc.setAuthentication('BASIC');
|
|
202
|
+
svc.setRequestMethod('GET');
|
|
203
|
+
return null;
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
parseResponse: function (svc, client) {
|
|
207
|
+
return JSON.parse(client.text);
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
filterLogMessage: function (msg) {
|
|
211
|
+
// Filter Authorization header
|
|
212
|
+
return msg.replace(/Authorization:\s*Basic\s+[^\r\n]+/gi, 'Authorization: Basic ***');
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Bearer Token (OAuth)
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
var oauthService = LocalServiceRegistry.createService('my.oauth.api', {
|
|
221
|
+
createRequest: function (svc, params) {
|
|
222
|
+
var token = params.accessToken;
|
|
223
|
+
svc.setAuthentication('NONE'); // Don't use basic auth
|
|
224
|
+
svc.setRequestMethod('GET');
|
|
225
|
+
svc.addHeader('Authorization', 'Bearer ' + token);
|
|
226
|
+
return null;
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
parseResponse: function (svc, client) {
|
|
230
|
+
return JSON.parse(client.text);
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
filterLogMessage: function (msg) {
|
|
234
|
+
return msg.replace(/Bearer\s+[^\s\r\n]+/gi, 'Bearer ***');
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### API Key Authentication
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
var apiKeyService = LocalServiceRegistry.createService('my.apikey.api', {
|
|
243
|
+
createRequest: function (svc, params) {
|
|
244
|
+
var credential = svc.configuration.credential;
|
|
245
|
+
svc.setAuthentication('NONE');
|
|
246
|
+
svc.setRequestMethod('GET');
|
|
247
|
+
// API key in header
|
|
248
|
+
svc.addHeader('X-API-Key', credential.password);
|
|
249
|
+
return null;
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
parseResponse: function (svc, client) {
|
|
253
|
+
return JSON.parse(client.text);
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
filterLogMessage: function (msg) {
|
|
257
|
+
return msg.replace(/X-API-Key:\s*[^\r\n]+/gi, 'X-API-Key: ***');
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### OAuth 2.0 Client Credentials Flow
|
|
263
|
+
|
|
264
|
+
```javascript
|
|
265
|
+
// Token service
|
|
266
|
+
var tokenService = LocalServiceRegistry.createService('my.oauth.token', {
|
|
267
|
+
createRequest: function (svc, params) {
|
|
268
|
+
svc.setRequestMethod('POST');
|
|
269
|
+
svc.addHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
270
|
+
|
|
271
|
+
var credential = svc.configuration.credential;
|
|
272
|
+
var body = 'grant_type=client_credentials';
|
|
273
|
+
body += '&client_id=' + encodeURIComponent(credential.user);
|
|
274
|
+
body += '&client_secret=' + encodeURIComponent(credential.password);
|
|
275
|
+
|
|
276
|
+
return body;
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
parseResponse: function (svc, client) {
|
|
280
|
+
return JSON.parse(client.text);
|
|
281
|
+
},
|
|
282
|
+
|
|
283
|
+
filterLogMessage: function (msg) {
|
|
284
|
+
msg = msg.replace(/client_secret=[^&\s]+/gi, 'client_secret=***');
|
|
285
|
+
msg = msg.replace(/"access_token"\s*:\s*"[^"]+"/gi, '"access_token":"***"');
|
|
286
|
+
return msg;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// Get token and use it
|
|
291
|
+
function callApiWithOAuth(params) {
|
|
292
|
+
// Get access token
|
|
293
|
+
var tokenResult = tokenService.call();
|
|
294
|
+
if (!tokenResult.ok) {
|
|
295
|
+
throw new Error('Failed to get access token');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var accessToken = tokenResult.object.access_token;
|
|
299
|
+
|
|
300
|
+
// Call API with token
|
|
301
|
+
var apiService = LocalServiceRegistry.createService('my.protected.api', {
|
|
302
|
+
createRequest: function (svc, params) {
|
|
303
|
+
svc.setAuthentication('NONE');
|
|
304
|
+
svc.addHeader('Authorization', 'Bearer ' + accessToken);
|
|
305
|
+
svc.setRequestMethod('GET');
|
|
306
|
+
return null;
|
|
307
|
+
},
|
|
308
|
+
parseResponse: function (svc, client) {
|
|
309
|
+
return JSON.parse(client.text);
|
|
310
|
+
},
|
|
311
|
+
filterLogMessage: function (msg) {
|
|
312
|
+
return msg.replace(/Bearer\s+[^\s\r\n]+/gi, 'Bearer ***');
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
return apiService.call(params);
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## Form Submissions (HTTPForm)
|
|
321
|
+
|
|
322
|
+
For `application/x-www-form-urlencoded` submissions:
|
|
323
|
+
|
|
324
|
+
```javascript
|
|
325
|
+
var formService = LocalServiceRegistry.createService('my.form.api', {
|
|
326
|
+
// HTTPForm automatically handles form encoding
|
|
327
|
+
// Pass a Map or Object as the call parameter
|
|
328
|
+
parseResponse: function (svc, client) {
|
|
329
|
+
return client.text;
|
|
330
|
+
},
|
|
331
|
+
|
|
332
|
+
filterLogMessage: function (msg) {
|
|
333
|
+
return msg.replace(/password=[^&]+/gi, 'password=***');
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// Usage - pass a Map for form data
|
|
338
|
+
var HashMap = require('dw/util/HashMap');
|
|
339
|
+
var formData = new HashMap();
|
|
340
|
+
formData.put('username', 'user@example.com');
|
|
341
|
+
formData.put('action', 'subscribe');
|
|
342
|
+
|
|
343
|
+
var result = formService.call(formData);
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Multipart Form Data
|
|
347
|
+
|
|
348
|
+
For file uploads:
|
|
349
|
+
|
|
350
|
+
```javascript
|
|
351
|
+
var HTTPRequestPart = require('dw/net/HTTPRequestPart');
|
|
352
|
+
|
|
353
|
+
var uploadService = LocalServiceRegistry.createService('my.upload.api', {
|
|
354
|
+
createRequest: function (svc, params) {
|
|
355
|
+
svc.setRequestMethod('POST');
|
|
356
|
+
|
|
357
|
+
var parts = [];
|
|
358
|
+
|
|
359
|
+
// Text field
|
|
360
|
+
parts.push(new HTTPRequestPart('description', params.description));
|
|
361
|
+
|
|
362
|
+
// File field
|
|
363
|
+
parts.push(new HTTPRequestPart(
|
|
364
|
+
'file',
|
|
365
|
+
params.file,
|
|
366
|
+
params.filename,
|
|
367
|
+
params.contentType
|
|
368
|
+
));
|
|
369
|
+
|
|
370
|
+
return parts; // Array of HTTPRequestPart triggers multipart
|
|
371
|
+
},
|
|
372
|
+
|
|
373
|
+
parseResponse: function (svc, client) {
|
|
374
|
+
return JSON.parse(client.text);
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
filterLogMessage: function (msg) {
|
|
378
|
+
return msg;
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
// Usage
|
|
383
|
+
var File = require('dw/io/File');
|
|
384
|
+
var file = new File(File.IMPEX + '/src/upload.csv');
|
|
385
|
+
var result = uploadService.call({
|
|
386
|
+
description: 'Product import',
|
|
387
|
+
file: file,
|
|
388
|
+
filename: 'products.csv',
|
|
389
|
+
contentType: 'text/csv'
|
|
390
|
+
});
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Downloading Files
|
|
394
|
+
|
|
395
|
+
```javascript
|
|
396
|
+
var File = require('dw/io/File');
|
|
397
|
+
|
|
398
|
+
var downloadService = LocalServiceRegistry.createService('my.download.api', {
|
|
399
|
+
createRequest: function (svc, params) {
|
|
400
|
+
svc.setRequestMethod('GET');
|
|
401
|
+
svc.setURL(svc.URL + '/files/' + params.fileId);
|
|
402
|
+
|
|
403
|
+
// Write response directly to file
|
|
404
|
+
var outFile = new File(File.IMPEX + '/src/' + params.filename);
|
|
405
|
+
svc.setOutFile(outFile);
|
|
406
|
+
|
|
407
|
+
return null;
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
parseResponse: function (svc, client) {
|
|
411
|
+
return {
|
|
412
|
+
success: client.statusCode === 200,
|
|
413
|
+
file: svc.outFile
|
|
414
|
+
};
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
filterLogMessage: function (msg) {
|
|
418
|
+
return msg;
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
## Response Caching
|
|
424
|
+
|
|
425
|
+
Enable caching for GET requests:
|
|
426
|
+
|
|
427
|
+
```javascript
|
|
428
|
+
var cachedService = LocalServiceRegistry.createService('my.cached.api', {
|
|
429
|
+
createRequest: function (svc, params) {
|
|
430
|
+
svc.setRequestMethod('GET');
|
|
431
|
+
// Cache for 5 minutes
|
|
432
|
+
svc.setCachingTTL(300);
|
|
433
|
+
return null;
|
|
434
|
+
},
|
|
435
|
+
|
|
436
|
+
parseResponse: function (svc, client) {
|
|
437
|
+
return JSON.parse(client.text);
|
|
438
|
+
},
|
|
439
|
+
|
|
440
|
+
filterLogMessage: function (msg) {
|
|
441
|
+
return msg;
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
Caching restrictions:
|
|
447
|
+
- Only GET requests
|
|
448
|
+
- Only 2xx status codes
|
|
449
|
+
- Response < 50KB
|
|
450
|
+
- Response not written to file
|
|
451
|
+
|
|
452
|
+
## Custom HTTP Client Configuration
|
|
453
|
+
|
|
454
|
+
Override HTTP client options:
|
|
455
|
+
|
|
456
|
+
```javascript
|
|
457
|
+
var customService = LocalServiceRegistry.createService('my.custom.api', {
|
|
458
|
+
initServiceClient: function (svc) {
|
|
459
|
+
// Return configuration options
|
|
460
|
+
return {
|
|
461
|
+
allowHTTP2: true
|
|
462
|
+
};
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
createRequest: function (svc, params) {
|
|
466
|
+
svc.setRequestMethod('GET');
|
|
467
|
+
return null;
|
|
468
|
+
},
|
|
469
|
+
|
|
470
|
+
parseResponse: function (svc, client) {
|
|
471
|
+
return JSON.parse(client.text);
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
filterLogMessage: function (msg) {
|
|
475
|
+
return msg;
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## Mutual TLS (mTLS)
|
|
481
|
+
|
|
482
|
+
For client certificate authentication:
|
|
483
|
+
|
|
484
|
+
```javascript
|
|
485
|
+
var KeyRef = require('dw/crypto/KeyRef');
|
|
486
|
+
|
|
487
|
+
var mtlsService = LocalServiceRegistry.createService('my.mtls.api', {
|
|
488
|
+
createRequest: function (svc, params) {
|
|
489
|
+
// Set client certificate
|
|
490
|
+
svc.setIdentity(new KeyRef('my-client-cert'));
|
|
491
|
+
svc.setRequestMethod('GET');
|
|
492
|
+
return null;
|
|
493
|
+
},
|
|
494
|
+
|
|
495
|
+
parseResponse: function (svc, client) {
|
|
496
|
+
return JSON.parse(client.text);
|
|
497
|
+
},
|
|
498
|
+
|
|
499
|
+
filterLogMessage: function (msg) {
|
|
500
|
+
return msg;
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
## XML API Example
|
|
506
|
+
|
|
507
|
+
```javascript
|
|
508
|
+
var xmlService = LocalServiceRegistry.createService('my.xml.api', {
|
|
509
|
+
createRequest: function (svc, params) {
|
|
510
|
+
svc.setRequestMethod('POST');
|
|
511
|
+
svc.addHeader('Content-Type', 'application/xml');
|
|
512
|
+
svc.addHeader('Accept', 'application/xml');
|
|
513
|
+
|
|
514
|
+
var xml = new XML('<request/>');
|
|
515
|
+
xml.@id = params.id;
|
|
516
|
+
xml.name = params.name;
|
|
517
|
+
|
|
518
|
+
return xml.toXMLString();
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
parseResponse: function (svc, client) {
|
|
522
|
+
var responseXml = new XML(client.text);
|
|
523
|
+
return {
|
|
524
|
+
status: responseXml.status.toString(),
|
|
525
|
+
message: responseXml.message.toString()
|
|
526
|
+
};
|
|
527
|
+
},
|
|
528
|
+
|
|
529
|
+
filterLogMessage: function (msg) {
|
|
530
|
+
return msg;
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
## Error Response Handling
|
|
536
|
+
|
|
537
|
+
```javascript
|
|
538
|
+
var robustService = LocalServiceRegistry.createService('my.robust.api', {
|
|
539
|
+
createRequest: function (svc, params) {
|
|
540
|
+
svc.setRequestMethod('POST');
|
|
541
|
+
svc.addHeader('Content-Type', 'application/json');
|
|
542
|
+
return JSON.stringify(params);
|
|
543
|
+
},
|
|
544
|
+
|
|
545
|
+
parseResponse: function (svc, client) {
|
|
546
|
+
var response = {
|
|
547
|
+
statusCode: client.statusCode,
|
|
548
|
+
success: false,
|
|
549
|
+
data: null,
|
|
550
|
+
errors: []
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
if (client.statusCode >= 200 && client.statusCode < 300) {
|
|
554
|
+
response.success = true;
|
|
555
|
+
try {
|
|
556
|
+
response.data = JSON.parse(client.text);
|
|
557
|
+
} catch (e) {
|
|
558
|
+
response.data = client.text;
|
|
559
|
+
}
|
|
560
|
+
} else {
|
|
561
|
+
// Try to parse error response
|
|
562
|
+
var errorBody = client.errorText || client.text;
|
|
563
|
+
try {
|
|
564
|
+
var errorData = JSON.parse(errorBody);
|
|
565
|
+
response.errors = errorData.errors || [errorData.message];
|
|
566
|
+
} catch (e) {
|
|
567
|
+
response.errors = [errorBody || 'Unknown error'];
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return response;
|
|
572
|
+
},
|
|
573
|
+
|
|
574
|
+
filterLogMessage: function (msg) {
|
|
575
|
+
return msg;
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
```
|