feat(#748): add interceptors prop to SDK hooks and CommerceLayer component#750
Merged
feat(#748): add interceptors prop to SDK hooks and CommerceLayer component#750
Conversation
…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
…s, remove endpoint
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for SDK interceptors across the hooks and React components layers.
Changes
packages/coreInterceptorManagertype viagetSdkand all core resource functionspackages/hooksuseSkus,useSkuLists,useAvailability,usePrices— accept optionalinterceptorsparam and forward to SDK clientpackages/react-componentsCommerceLayerContext— addedinterceptors?: InterceptorManager, removedendpoint<CommerceLayer>— removedendpointanddomainprops (no longer needed), addedinterceptorsprop<SkusContainer>— passesinterceptorsfrom context touseSkus<SkuListsContainer>— passesinterceptorsfrom context touseSkuLists<AvailabilityContainer>— passesinterceptorsfrom context touseAvailabilityendpointfrom context