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

@contentful/optimization-api-schemas

v0.1.0-alpha8

Published

<p align="center"> <a href="https://www.contentful.com/developers/docs/personalization/"> <img alt="Contentful Logo" title="Contentful" src="../../contentful-icon.png" width="150"> </a> </p>

Readme

Readme · Reference · Contributing

[!WARNING]

The Optimization SDK Suite is currently ALPHA! Breaking changes may be published at any time.

The Contentful Optimization API Schema Library is a collection of Zod Mini schemas and their inferred TypeScript types. These schemas help provide run-time validation when working with requests and responses for the APIs referenced within Optimization SDKs.

Getting Started

Install using an NPM-compatible package manager, pnpm for example:

pnpm install @contentful/optimization-api-schemas

Consult Zod's documentation for more information on working with Zod Mini schemas.

Contentful CDA Schemas

These schemas assist in determining whether Contentful content entries provided by the CDA and its SDK are valid for personalization. These schemas do not encapsulate all features and functionality specified in the CDA SDK's exported TypeScript type system, but strive to remain compatible enough for the purposes of personalization.

Essential Schemas

  • CtflEntry: Zod schema describing a generic Contentful entry; the fields member is loosely typed as any valid JSON
  • PersonalizedEntry: Zod schema describing a CtflEntry that has associated personalization entries
  • PersonalizationEntry: Zod schema describing a personalization entry, which is associated with a PersonalizedEntry via its fields.nt_experiences property
  • PersonalizationConfig: Zod schema describing the configuration of a PersonalizationEntry via its fields.nt_config property

Essential Functions

  • isEntry<S extends SkeletonType, M extends ChainModifiers, L extends string>: Type guard that checks whether the given value is a Contentful Entry, passing through the specified skeleton, chain modifiers, and locale
  • isPersonalizedEntry: Type guard for PersonalizedEntry
  • isPersonalizationEntry: Type guard for PersonalizationEntry

Experience API Schemas

These schemas help validate at run-time that both the request and response data for Experience API requests conform to current API specifications.

Essential Experience API Request Schemas

  • ExperienceRequestData: Zod schema describing the data payload for an experience request
  • ExperienceEvent: Zod schema union of supported experience/personalization events
  • BatchExperienceEvent: Zod schema describing each valid experience/personalization event within a batch; Similar to ExperienceEvent, but with an additional anonymousId member on each event schema

Experience/personalization event schemas:

  • AliasEvent: Zod schema describing an alias event
  • ComponentViewEvent: Zod schema describing a component view event (may be a Contentful entry or a Custom Flag)
  • IdentifyEvent: Zod schema describing an identify event
  • PageViewEvent: Zod schema describing a page view event
  • ScreenViewEvent: Zod schema describing a screen view event
  • TrackEvent: Zod schema describing a custom track event

Essential Experience API Response Schemas

  • ExperienceResponse: Zod schema describing a full Experience API response; includes a data object with changes, experiences, and profile properties
  • BatchExperienceResponse: Zod schema describing a batch experience response from the Experience API; includes a profiles collection
  • Change: Union of supported change types, which currently only includes VariableChange; this change type is used for Custom Flags
  • SelectedPersonalization: Zod schema describing a selected personalization outcome for a user
  • Profile: Zod schema describing a full user profile as received from the Experience API

Insights API Schemas

Insights API endpoints currently do not return response data.

Essential Insights API Response Schemas

  • InsightsEvent: Zod schema union of supported insights/analytics events
  • BatchInsightsEvent: Zod schema describing a batched Insights event payload; expects a profile property alongside a collection of events

Insights/analytics event schemas:

  • ComponentViewEvent: Zod schema describing a component view event (may be a Contentful entry or a Custom Flag)