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-alpha14

Published

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

Downloads

429

Readme

Guides · Reference · Contributing

[!WARNING]

The Optimization SDK Suite is pre-release (alpha). Breaking changes can be published at any time.

The Contentful Optimization API Schema Library provides Zod Mini schemas, inferred TypeScript types, and small runtime helpers for Contentful CDA, Experience API, and Insights API payloads. SDK layers use this package to validate API contracts and normalize optimization data.

Getting started

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

pnpm install @contentful/optimization-api-schemas

Import schemas or helpers from the package:

import { isOptimizedEntry, normalizeOptimizationConfig } from '@contentful/optimization-api-schemas'

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

When to use this package

Use @contentful/optimization-api-schemas when you need shared runtime validation schemas or inferred TypeScript types for Contentful CDA, Experience API, and Insights API payloads. Most application integrations must use an environment SDK instead of importing schemas directly.

Package surface

Contentful CDA helpers

These helpers identify and normalize Contentful entries for optimization:

| Export | Purpose | | ----------------------------- | --------------------------------------------------------------- | | CtflEntry | Generic Contentful entry schema | | OptimizedEntry | Entry schema with associated optimization entries | | OptimizationEntry | Optimization entry schema referenced by fields.nt_experiences | | OptimizationConfig | Optimization configuration schema from fields.nt_config | | isEntry | Type guard for Contentful Entry values | | isOptimizedEntry | Type guard for optimized entries | | isOptimizationEntry | Type guard for optimization entries | | normalizeOptimizationConfig | Fills omitted optimization config fields with SDK-safe defaults |

These schemas model the SDK's single-locale CDA entry contract. Fetch entries in the app layer with one CDA locale. Use the resolved SDK locale, withOptimizationLocale(contentfulClient), or the Node SDK's resolveRequestLocale() result before passing entries to SDK resolution helpers. Avoid withAllLocales or locale=* in that path. See Entry personalization and variant resolution for the entry contract and Locale handling in the Optimization SDK Suite for the broader locale model.

Experience API schemas

Experience API schemas validate profile evaluation request and response payloads:

| Export | Purpose | | ---------------------------- | -------------------------------------------------------- | | ExperienceRequestData | Request payload for a single Experience API call | | BatchExperienceRequestData | Request payload for batch Experience API calls | | ExperienceEvent | Union of supported Experience API event schemas | | BatchExperienceEvent | Batch event schema with required anonymousId per event | | ExperienceResponse | Full Experience API response envelope | | BatchExperienceResponse | Batch Experience API response envelope | | Change | Supported change union, including Custom Flag data | | SelectedOptimization | Selected optimization outcome for a profile | | Profile | User profile returned by the Experience API |

Insights API schemas

Insights API schemas validate event ingestion payloads:

| Export | Purpose | | -------------------- | ----------------------------------------------------------- | | InsightsEvent | Union of supported Insights API event schemas | | BatchInsightsEvent | Batched Insights API payload with profile and event entries | | ClickEvent | component_click event schema | | HoverEvent | component_hover event schema | | ViewEvent | component view event schema |

For every schema, inferred type, and helper signature, use the generated API Schemas reference.

Related