add initial versions of createCentraProductsCache*Helpers + cacheAside#424
add initial versions of createCentraProductsCache*Helpers + cacheAside#424adamsoderstrom wants to merge 4 commits intofeature/create-get-centra-webhook-eventsfrom
createCentraProductsCache*Helpers + cacheAside#424Conversation
🦋 Changeset detectedLatest commit: 595fd1b The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
createCentraProductsCache*Helpers** + createCacheAside + createCompareByIndex
| }) | ||
|
|
||
| // Get entries from external service | ||
| const entriesFromFallback = await fallback(entries, ...args) |
There was a problem hiding this comment.
todo: pass missingKeys, instead of entries
The fallback callback shouldn't have to filter out the missingKeys based on the entries.
I do feel that this function does too much now.
The passed fallback callback is expected to verify that entries are the ones retrieved and fetch additional data if needed. Looking on how the function is used shows that there's really no requirements applied on fallback which i think we should strive for.
createCentraProductsCache*Helpers** + createCacheAside + createCompareByIndexcreateCentraProductsCache*Helpers + createCacheAside + createCompareByIndex
createCentraProductsCache*Helpers + createCacheAside + createCompareByIndexcreateCentraProductsCache*Helpers + createCacheAside + createCompareByIndex
| return Object.values(grouped) | ||
| } | ||
|
|
||
| export function pagesRouterApiAdapter<TProduct extends ProductBase>( |
There was a problem hiding this comment.
thought: can we reuse the adapter from createGetCentraWebhookEvents?
todo: add a appRouterApiAdapter
packages/next-centra-checkout/src/createCentraProductsCacheServerHelpers.ts
Outdated
Show resolved
Hide resolved
packages/next-centra-checkout/src/createCentraProductsCacheServerHelpers.ts
Outdated
Show resolved
Hide resolved
7f99666 to
2d0d2c8
Compare
createCentraProductsCache*Helpers + createCacheAside + createCompareByIndexcreateCentraProductsCache*Helpers + createCacheAside
be41748 to
88d9f92
Compare
88d9f92 to
078e4f2
Compare
078e4f2 to
44d5b19
Compare
packages/next-centra-checkout/src/createCentraProductsCacheServerHelpers.ts
Outdated
Show resolved
Hide resolved
44d5b19 to
cc61567
Compare
1922b61 to
193072a
Compare
193072a to
c20c2b4
Compare
f30d3cc to
23b1375
Compare
c20c2b4 to
b6a39f4
Compare
23b1375 to
7de2df1
Compare
b6a39f4 to
46ad11a
Compare
46ad11a to
8df26d1
Compare
b9cbe8b to
a64f348
Compare
d0a7415 to
806f664
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces initial versions of cacheAside utility and Centra products cache helpers for Next.js applications. The changes enable cache-aside pattern implementation and provide server/client helpers for managing Centra product caching in Next.js environments.
- Adds
cacheAsideutility function with cache-aside pattern implementation - Creates Centra product cache server and client helpers for Next.js
- Includes comprehensive test coverage for all new functionality
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/utils/src/cacheAside.ts | Implements cache-aside pattern utility with type-safe interfaces |
| packages/utils/src/cacheAside.test.ts | Comprehensive test coverage for cacheAside functionality |
| packages/next-centra-checkout/src/createGetCentraWebhookEvents.ts | Webhook event handler with signature verification |
| packages/next-centra-checkout/src/createCentraProductsCacheServerHelpers.ts | Server-side helpers for Centra product caching with Next.js adapters |
| packages/next-centra-checkout/src/createCentraProductsCacheClientHelpers.ts | Client-side helper for fetching cached Centra products |
| packages/next-centra-checkout/package.json | New package configuration with dependencies and build setup |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
packages/utils/src/cacheAside.ts
Outdated
| } | ||
|
|
||
| if (Array.isArray(param)) { | ||
| const missedArgs = param.filter((p): p is TParam => !isHit(p, cacheResults)) |
There was a problem hiding this comment.
Type assertion p is TParam is incorrect when param is an array. The filter should cast to the element type, not the entire parameter type. This should be p is TParam extends unknown[] ? TParam[number] : never.
| const missedArgs = param.filter((p): p is TParam => !isHit(p, cacheResults)) | |
| const missedArgs = param.filter((p): p is TParam extends unknown[] ? TParam[number] : never => !isHit(p, cacheResults)) |
packages/next-centra-checkout/src/createCentraProductsCacheServerHelpers.ts
Outdated
Show resolved
Hide resolved
packages/next-centra-checkout/src/createCentraProductsCacheServerHelpers.ts
Outdated
Show resolved
Hide resolved
packages/next-centra-checkout/src/createCentraProductsCacheClientHelpers.ts
Outdated
Show resolved
Hide resolved
806f664 to
b2d6aeb
Compare
b2d6aeb to
806f664
Compare
a81618d to
c9a892d
Compare
cacheAsidecreateCentraProductsCache*Helpers