-
Notifications
You must be signed in to change notification settings - Fork 3
add initial versions of createCentraProductsCache*Helpers + cacheAside
#424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/create-get-centra-webhook-events
Are you sure you want to change the base?
add initial versions of createCentraProductsCache*Helpers + cacheAside
#424
Conversation
🦋 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
b9cbe8b to
a64f348
Compare
d0a7415 to
806f664
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)) |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
806f664 to
071ab3c
Compare
071ab3c to
9a44149
Compare
c9a892d to
068abe7
Compare
9a44149 to
bd3c764
Compare
bd3c764 to
37094ba
Compare
db0f6fc to
a340428
Compare
…oductsCache*Helpers`
37094ba to
595fd1b
Compare
a340428 to
1c87da3
Compare
cacheAsidecreateCentraProductsCache*Helpers