Skip to content

Conversation

@adamsoderstrom
Copy link
Member

@adamsoderstrom adamsoderstrom commented Mar 17, 2025

  • feat(utils): add initial version of cacheAside
  • feat(next-centra-checkout): create initial version of createCentraProductsCache*Helpers

@changeset-bot
Copy link

changeset-bot bot commented Mar 17, 2025

🦋 Changeset detected

Latest commit: 595fd1b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@noaignite/utils Minor
@noaignite/next-centra-checkout Patch
@noaignite/react-centra-checkout Patch
@noaignite/react-utils Patch
@noaignite/tailwind-typography Patch

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

@vercel
Copy link

vercel bot commented Mar 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs Ready Ready Preview Comment Sep 24, 2025 7:39pm

@adamsoderstrom adamsoderstrom changed the title feature/centra cache helpers create initial version of createCentraProductsCache*Helpers** + createCacheAside + createCompareByIndex Mar 17, 2025
})

// Get entries from external service
const entriesFromFallback = await fallback(entries, ...args)
Copy link
Member Author

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.

@adamsoderstrom adamsoderstrom changed the title create initial version of createCentraProductsCache*Helpers** + createCacheAside + createCompareByIndex create initial version of createCentraProductsCache*Helpers + createCacheAside + createCompareByIndex Mar 17, 2025
@adamsoderstrom adamsoderstrom changed the title create initial version of createCentraProductsCache*Helpers + createCacheAside + createCompareByIndex add initial versions of createCentraProductsCache*Helpers + createCacheAside + createCompareByIndex Mar 17, 2025
@adamsoderstrom adamsoderstrom marked this pull request as draft March 17, 2025 09:07
return Object.values(grouped)
}

export function pagesRouterApiAdapter<TProduct extends ProductBase>(
Copy link
Member Author

@adamsoderstrom adamsoderstrom Mar 17, 2025

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

@adamsoderstrom adamsoderstrom force-pushed the feature/centra-cache-helpers branch from 7f99666 to 2d0d2c8 Compare March 22, 2025 16:13
@adamsoderstrom adamsoderstrom changed the title add initial versions of createCentraProductsCache*Helpers + createCacheAside + createCompareByIndex add initial versions of createCentraProductsCache*Helpers + createCacheAside Mar 23, 2025
@adamsoderstrom adamsoderstrom force-pushed the feature/centra-cache-helpers branch 2 times, most recently from be41748 to 88d9f92 Compare March 24, 2025 22:25
@adamsoderstrom adamsoderstrom force-pushed the feature/centra-cache-helpers branch from 88d9f92 to 078e4f2 Compare March 24, 2025 22:28
@adamsoderstrom adamsoderstrom force-pushed the feature/centra-cache-helpers branch from 078e4f2 to 44d5b19 Compare March 24, 2025 22:28
@adamsoderstrom adamsoderstrom force-pushed the feature/create-get-centra-webhook-events branch 2 times, most recently from b9cbe8b to a64f348 Compare July 2, 2025 11:53
@adamsoderstrom adamsoderstrom force-pushed the feature/centra-cache-helpers branch 2 times, most recently from d0a7415 to 806f664 Compare July 2, 2025 14:50
@maeertin maeertin requested a review from Copilot September 24, 2025 17:23
Copy link

Copilot AI left a 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 cacheAside utility 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.

}

if (Array.isArray(param)) {
const missedArgs = param.filter((p): p is TParam => !isHit(p, cacheResults))
Copy link

Copilot AI Sep 24, 2025

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.

Suggested change
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))

Copilot uses AI. Check for mistakes.
@adamsoderstrom adamsoderstrom force-pushed the feature/create-get-centra-webhook-events branch from c9a892d to 068abe7 Compare September 24, 2025 18:12
@adamsoderstrom adamsoderstrom force-pushed the feature/centra-cache-helpers branch from bd3c764 to 37094ba Compare September 24, 2025 18:20
@adamsoderstrom adamsoderstrom force-pushed the feature/create-get-centra-webhook-events branch 2 times, most recently from db0f6fc to a340428 Compare September 24, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants