npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@scayle/storefront-cms-amplience

v1.0.0

Published

Amplience CMS provider integration for the SCAYLE Storefront Application V3

Readme

@scayle/storefront-cms-amplience

Amplience CMS provider integration for the SCAYLE Storefront Application V3. Implements CMSProviderService from @scayle/storefront on top of Amplience Content Delivery 2, plus the Virtual Staging Environment helpers the provider's visualization paths need.

Package entrypoint

| Export | Use | | ---------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | AmplienceCMSService | Concrete CMSProviderService implementation. Generic over your generated Amplience content-type shape (TPageData), defaulting to CMSPagePayload. No abstract members, so it is usable without a subclass. | | AmplienceCMSServiceConfig | Constructor config shape: {hubName, draftContentEnabled}. | | cspConfig | CMSCspConfig for Amplience visualization: Dynamic Content iframe embedding plus the Dynamic Media connect-src the video metadata request needs. | | parseCategoryIdFromAmplienceDeliveryKey | Parses the category ID back out of a PLP delivery key, which is all Amplience exposes in {{delivery.key}}. | | isAmplienceCategoryRoutePath, resolveAmpliencePlpPreviewPath | Category-route detection, and rewriting the PLP visualization placeholder path to carry the real category ID. |

VSE parsing and editor detection stay internal; editor detection is reachable through AmplienceCMSService.isEditorMode().

Dynamic Media URL building lives in the application, not here: src/client/cms/providers/amplience/utils/media.ts, next to the other providers' media helpers and on top of the shared getSources breakpoint logic. Those builders touch no vendor SDK, and the breakpoints, formats, and quality defaults they encode are presentation choices you edit, so freezing them behind a package release would be the wrong boundary.

See Amplience's Content Delivery documentation and the Dynamic Media reference for the underlying APIs.

Configuration

| Option | Required | Description | | --------------------- | -------- | ---------------------------------------------------------------------- | | hubName | Yes | Content Delivery 2 hub name, used as the delivery subdomain. | | draftContentEnabled | Yes | Whether a visualization request may serve unpublished staging content. |

The package never reads process.env itself. The boilerplate is the sole place reading environment variables (AMPLIENCE_CMS_HUB_NAME, STOREFRONT_CMS_ALLOW_DRAFTS) and passes plain values in.

Usage

AmplienceCMSService has no abstract members, so it works without a subclass. The Storefront Application's src/server/cms/providers/amplience/service.ts still wraps it in a thin subclass for consistency with the other providers and as your override point:

import { AmplienceCMSService as BaseAmplienceCMSService } from '@scayle/storefront-cms-amplience'

export class AmplienceCMSService extends BaseAmplienceCMSService {}

export const createCMSService = (storefront: StorefrontContext) =>
  new AmplienceCMSService(
    {
      hubName: getRequiredEnv('AMPLIENCE_CMS_HUB_NAME'),
      draftContentEnabled:
        process.env.STOREFRONT_CMS_ALLOW_DRAFTS?.toLowerCase() === 'true',
    },
    storefront,
  )

The Storefront Application registers createCMSService(storefront) as the cms slot on the ServiceRegistry (src/server/registries.ts). Controllers resolve it from there and pass IncomingRequest:

const pageData = await services.cms.fetchPageData(slug, ctx.get('request'))

Architecture

AmplienceCMSService implements CMSProviderService directly. Each provider package owns its own caching, error handling, and constructor validation, so this package can diverge from the others without a @scayle/storefront release touching them.

Content items are locale-bound, so lookups go through delivery keys

Amplience Content Delivery 2 localizes at the content-item level rather than by delivery endpoint. The client is therefore locale-agnostic, and every lookup is a locale-prefixed delivery key:

  • Content pages: {locale}/{slug}, for example de-DE/content/about or en-GB/homepage.
  • Category pages: {locale}/c/c-{categoryId}, for example en-US/c/c-91825.

Both come from protected buildPageDeliveryKey / buildListingDeliveryKey, so a subclass can change the delivery-key layout without reimplementing the fetch path.

Category pages do not use Amplience's Filter API. Because Content Delivery 2 binds items to a locale, an item with no explicit locale assignment falls outside the delivery-layer locale filter and is simply not returned, even though it exists in the hub. That made filter-based resolution unreliable. The V2 provider reached the same conclusion; its reasoning is recorded in v2/boilerplate/modules/cms/providers/amplience/AMPLIENCE.md.

Caching

fetchPageData and fetchListingPageData wrap the raw fetch in context.cache.getOrSet(...) with a 5-minute TTL, under cms:amplience:page:{deliveryKey} and cms:amplience:plp:{deliveryKey}. The key is the delivery key rather than slug plus locale, because the delivery key already encodes both. Preview requests bypass the cache entirely.

fetchListingPageData converts a CMSContentNotFoundError into undefined — most categories have no CMS content, and that is not an error. Any other error is rethrown for the caller to log.

Client instances

Published delivery clients are lazily initialized and cached statically, keyed by hub name, so they are reused across requests without two hubs in one process sharing a client. A Virtual Staging Environment client is built per request instead, because the staging domain is issued per editor session and a shared instance would serve one editor's drafts to another. Both go through @scayle/storefront/cms's wrapClientInit, so a bad hub name fails with a message naming the config field to check rather than a bare SDK error.

The delivery SDK returns content wrapped in classes carrying toJSON hooks, which do not survive serialization into Inertia page props. The payload is round-tripped through JSON to get plain objects.

Preview

Amplience drives in-CMS preview by loading the storefront in an iframe with two query parameters:

  • vse (or _vse on older visualization templates) — the per-session staging domain. Its presence is the editor-mode signal, and isEditorMode() keys off it. The value becomes the base URL the delivery SDK fetches from, so it is accepted only when it matches an Amplience staging domain (<session>.staging.bigcontent.io); any other host is logged and ignored as if no vse had been passed.
  • key — the delivery key of the item the editor currently has open, substituted from {{delivery.key}}. In a draft-enabled preview session this wins over the delivery key derived from the URL, so the editor sees exactly the item it has open.

Draft preview requires both a vse parameter and draftContentEnabled. Without the flag the service ignores the VSE domain and serves published content, which is what keeps production safe if a visualization URL leaks. Leave STOREFRONT_CMS_ALLOW_DRAFTS unset in production.

getCMSEditorData() returns the VSE hostname and open delivery key for the client-side visualization bridge, under the same staging check the fetch path uses. With draftContentEnabled off it returns undefined, so the client is not told to talk to an environment the server just declined to read from.

Product listing page visualization

Amplience cannot inject a custom schema field into a visualization templatedUri, so the Product Listing Page content type opens preview at a placeholder path (/c/cms-preview-0) and passes the real delivery key as ?key=. parseCategoryIdFromAmplienceDeliveryKey recovers the category ID from that key and resolveAmpliencePlpPreviewPath rewrites the path to /c/cms-preview-{categoryId}, preserving any country prefix, so the category route can load products, filters, and navigation.

getPreviewRedirectPath(request, path) is the entry point that applies those two helpers, and it is what the application's preview redirect middleware calls (createCmsPreviewRedirectMiddleware from @scayle/storefront/cms). It returns the rewritten path in a visualization session on a category route whose key holds a category ID, and undefined otherwise, so any other request is served as-is. A path that already ends in that category ID is served as-is too, so the redirect does not fight the canonical path redirect the listing controller issues for a non-canonical slug.

Dynamic Media

Image and video URLs are built in the application (src/client/cms/providers/amplience/utils/media.ts), the same place the Storyblok, Contentful, and Contentstack media helpers live. The service itself never builds a media URL: it returns content payloads, and the components turn image-link and video-link objects into Dynamic Media URLs.

Extending and customizing

  • Override buildPageDeliveryKey / buildListingDeliveryKey to change the delivery-key layout.
  • Augment CMSEditorData with a declare module '@scayle/storefront/cms' block to add fields for a custom client-side editor bridge. This package already contributes vse and deliveryKey.
  • SEO metadata extraction lives in the Storefront Application (getPageMeta in the provider's service.ts), not here, since the field names come from your content model.