API
The package's ./api subpath exports the pure link resolver. The old read getters
(getPage, getArticle, getHeader, …) retired with the Convex migration — the
storefront now reads content straight from the Convex cms/read functions through
its own getter layer (apps/storefront/src/api/), and this package is not in that
wire path.
import { resolveLink, type LinkValue, type LocaleRef } from '@nordcom/commerce-cms/api';resolveLink
Turns the CMS linkField shape into a storefront URL.
import { resolveLink } from '@nordcom/commerce-cms/api';
resolveLink({ kind: 'page', page: { slug: 'about' } }, { locale }); // → /en-US/about/
resolveLink({ kind: 'product', product: { shopifyHandle: 'hat' } }, { locale });
// → /en-US/products/hat/Supports external, anchor, page, article, product, and collection
link kinds. The render-time LinkRef shape (in blocks/render/types.ts) carries
loose values for editor-side defaults; the loader pipeline coerces them into the
strict LinkValue shape before calling resolveLink.
Where the reads live now
- Storefront reads —
apps/storefront/src/api/{header,footer,page,article,…}.tscall the Convexcms/readfunctions through the injectable transport insrc/api/_cms-read.ts. The result types come from this package's generated./types(content-types.ts). - Editor reads/writes — the admin's generated action wrappers
(
apps/admin/src/lib/cms-actions/_generated/) call the Convexcms/documentsfunctions (drafts, autosave, versions, publish).
Cache invalidation
Publishing a document runs the Convex revalidation pipeline, which computes tags
from the shared schema in ./cache-descriptor and delivers signed events to the
storefront's /api/revalidate/convex route:
cms.<shopId>.<collection>.<key> # e.g. cms.shop-1.pages.home
cms.<shopId>.<collection> # e.g. cms.shop-1.pages
cms.<shopId> # broad sweep for the whole tenant<key> is the slug for pages/articles, the shopifyHandle for
product/collection metadata, or the doc id for globals. Storefront read paths
attach all three tags so a single edit invalidates exactly what changed without
sweeping the whole site.
For tenant-root reads that aren't entity-specific (e.g. sitemap indexes), use
cmsTenantRootTags(shop) from @nordcom/commerce-cms/cache to get the matching
fanout tags.