Skip to content

feat(#748): add interceptors prop to SDK hooks and CommerceLayer component#750

Merged
acasazza merged 5 commits intov5.0.0from
feat/748-sdk-interceptors
Apr 17, 2026
Merged

feat(#748): add interceptors prop to SDK hooks and CommerceLayer component#750
acasazza merged 5 commits intov5.0.0from
feat/748-sdk-interceptors

Conversation

@acasazza
Copy link
Copy Markdown
Member

Summary

Adds support for SDK interceptors across the hooks and React components layers.

Changes

packages/core

  • Expose InterceptorManager type via getSdk and all core resource functions

packages/hooks

  • useSkus, useSkuLists, useAvailability, usePrices — accept optional interceptors param and forward to SDK client
  • 100% test coverage maintained (added missing interceptor tests)
  • Biome formatting applied

packages/react-components

  • CommerceLayerContext — added interceptors?: InterceptorManager, removed endpoint
  • <CommerceLayer> — removed endpoint and domain props (no longer needed), added interceptors prop
  • <SkusContainer> — passes interceptors from context to useSkus
  • <SkuListsContainer> — passes interceptors from context to useSkuLists
  • <AvailabilityContainer> — passes interceptors from context to useAvailability
  • Tests updated to reflect removed endpoint from context
  • Biome lint fixes applied

…rces

- Rewrite getSdk in packages/core: uses jwtDecode for org slug,
  accepts optional interceptors?, applies request/response/rawReader
  interceptors via SDK client methods, returns CommerceLayerBundle
- Add InterceptorManager type built from SDK public exports
  (RequestObj, ResponseObj, ErrorObj)
- Export getSdk and InterceptorManager from packages/core index
- Add interceptors? to RequestConfig base type so all resource
  functions inherit it automatically
- Thread interceptors through all 9 resource functions:
  getSkus, retrieveSku, updateSku, getPrices, retrievePrice,
  updatePrice, getSkuLists, retrieveSkuList, getSkuAvailability
- 🧪 Add getSdk.spec.ts with 8 unit tests (100% coverage)
- 🧪 Add *.interceptors.spec.ts for every resource function
- 🎯 Achieve 100% statement/branch/function/line coverage across core

Closes #748 (partial - core package step)
…rage

- Apply biome format/organizeImports fixes across core and hooks packages
- Add clearSkuLists, retrieveSkuList error, and cache mutation tests for useSkuLists
- Add map-branch and fallback-branch tests for useSkus updateSku mutate callback
- Add c8 ignore to untestable defensive catch callbacks in useAvailability, useSkus, useSkuLists
- Add organizeImports biome action to .vscode/settings.json
@acasazza acasazza added the enhancement New feature or request label Apr 17, 2026
@acasazza acasazza self-assigned this Apr 17, 2026
@acasazza acasazza merged commit 041f1b5 into v5.0.0 Apr 17, 2026
1 check failed
@acasazza acasazza deleted the feat/748-sdk-interceptors branch April 17, 2026 10:24
@acasazza acasazza added components Components package javascript Pull requests that update javascript code labels Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components Components package enhancement New feature or request javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant