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

@lars-plate/delta-client

v1.1.15

Published

TypeScript utilities for building **Delta** frontends that integrate with [Plate](https://plate.dev) CMS. The package provides:

Readme

@lars-plate/delta-client

TypeScript utilities for building Delta frontends that integrate with Plate CMS. The package provides:

  • Window connectors — typed postMessage communication between a Plate preview host and an embedded experience (iframe)
  • Content Delivery API — fetch helpers for content experiences, content items, and tags
  • Content parsers — turn GraphQL ContentItem / experience-component data, or CDA “accessible” payloads, into plain JavaScript objects keyed by field slug
  • GraphQL types — generated TypeScript definitions for the Plate GraphQL schema
  • Link helpers — distinguish path parts from grid placements

Installation

npm install @lars-plate/delta-client
# or
pnpm add @lars-plate/delta-client
# or
yarn add @lars-plate/delta-client

Runtime: Window connectors need a browser (Window, postMessage). The Content Delivery API uses fetch and works in modern browsers and Node.js 18+.

Package exports

The library is published as an ES module with CommonJS builds. Import from the root or from subpaths:

| Import path | Description | |-------------|-------------| | @lars-plate/delta-client | Everything (connectors, parsers, graphql, api, utils) | | @lars-plate/delta-client/connectors | Window connector client & server | | @lars-plate/delta-client/parsers | Content parsing utilities | | @lars-plate/delta-client/graphql | Generated GraphQL TypeScript types | | @lars-plate/delta-client/api | Content Delivery API client | | @lars-plate/delta-client/utils | Path-part / grid-placement type guards |

// Full barrel
import { WindowConnectorClient, parseContentItem, type ContentExperience } from '@lars-plate/delta-client';

// Subpath imports (smaller bundles when tree-shaking)
import { WindowConnectorServer } from '@lars-plate/delta-client/connectors';
import { parseDataFromExperienceComponent } from '@lars-plate/delta-client/parsers';
import type { ContentItem, ExperienceComponent } from '@lars-plate/delta-client/graphql';
import { fetchContentExperienceByPath, Environment, Version } from '@lars-plate/delta-client/api';
import { isPathPart, isGridPlacement } from '@lars-plate/delta-client/utils';

Content Delivery API

Fetch published content from the Plate Content Delivery API (CDA). Pass a DeltaApiConfig to choose environment, API version, and bearer token. Omitted fields default to environment: Environment.PROD, version: Version.V1, and no token.

import {
  Environment,
  Version,
  fetchContentExperienceByPath,
  fetchContentExperienceByPrn,
  fetchContentExperiences,
  fetchContentItem,
  fetchContentItems,
  fetchTags,
  type DeltaApiConfig,
} from '@lars-plate/delta-client/api';

const config: DeltaApiConfig = {
  environment: Environment.DEV, // 'acc' | 'dev' | 'local' | 'prod'
  version: Version.V1,          // 'v0' | 'v1'
  token: process.env.DELTA_TOKEN,
};

| Environment | CDA base URL (environmentBaseUrlMap) | Editor origin (environmentEditorUrlMap) | |---------------|----------------------------------------|-------------------------------------------| | local | http://localhost:28164 | http://localhost:5173 | | dev | https://cda.dev.platedelta.eu | https://fe-dev.platedelta.eu | | acc | https://cda.acc.platedelta.eu | https://fe-acc.platedelta.eu | | prod | https://cda.platecms.app | https://www.platecms.app |

Use environmentEditorUrlMap as the connector origin when the experience iframe talks to the CMS editor.

Experiences

// Single experience — these return the raw `fetch` Response; call `.json()` yourself
const byPath = await fetchContentExperienceByPath('/home', config);
const experience = await byPath.json();

const byPrn = await fetchContentExperienceByPrn('prn:…:content-experience:…', config);
const same = await byPrn.json();

// Paginated list
const page = await fetchContentExperiences(
  { page: 1, limit: 20, slug_eq: 'home' },
  config,
);
// page.entities, page.meta.pagination, page.links

path is appended after /content-experiences/path, so it should start with / (for example '/blog/my-post').

Content items and tags

const item = await fetchContentItem('prn:…:content-item:…', config);

const items = await fetchContentItems(
  { page: 1, limit: 10, contentTypeSlug_eq: 'article' },
  config,
);

const tags = await fetchTags({ page: 1, limit: 50, name_like: 'news' }, config);

List helpers accept pagination (page, limit), sorting (orderByKey, orderByDirection), and field filters (*_eq, *_in, *_like, tag PRN filters, and so on). They return a PaginatedResponse<T> with entities, meta.pagination, and links.


Window connectors

Plate’s Delta preview runs your experience inside an iframe while the CMS UI lives in the parent window. Connectors wrap window.postMessage with:

  • Origin checks for security
  • A health-check handshake so the host knows when the iframe is alive
  • Typed events for CMS ↔ experience messaging

Architecture

┌─────────────────────────────┐         postMessage          ┌─────────────────────────────┐
│  Plate CMS (parent window)  │ ◄──────────────────────────► │  Your experience (iframe)   │
│  WindowConnectorServer      │   HEALTH_CHECK / RESPONSE    │  WindowConnectorClient      │
└─────────────────────────────┘   CONTENT_EXPERIENCE_SEND    └─────────────────────────────┘
                                  GRID_PLACEMENT_CLICKED
                                  ROOT_EXPERIENCE_COMPONENT_SEND

Connector status

The server emits status_changed as the link moves through:

| Status | Meaning | |--------|---------| | idle | No client configured or after teardown() | | connecting | Health checks in progress | | connected | Client responded to a health check | | disconnected | Max retries exceeded without a response |

Event types

| ConnectorEventType | Direction (typical) | Payload | |----------------------|---------------------|---------| | content-experience-send | Host → experience | Full ContentExperience GraphQL object | | root-experience-component-send | Host → experience | Root ExperienceComponent | | grid-placement-clicked | Experience → host | { prn, experienceComponentPrn } |

Server (parent / CMS side)

import {
  WindowConnectorServer,
  ConnectorStatus,
  ConnectorEventType,
} from '@lars-plate/delta-client/connectors';
import type { ContentExperience } from '@lars-plate/delta-client/graphql';

const iframe = document.querySelector<HTMLIFrameElement>('#delta-preview')!;
const childWindow = iframe.contentWindow!;
const childOrigin = 'https://your-experience.example.com';

const server = new WindowConnectorServer(window, 3); // 3 health-check retries

server
  .setClient(childWindow, childOrigin)
  .connect();

server.on('status_changed', ({ status }) => {
  if (status === ConnectorStatus.CONNECTED) {
    console.log('Experience iframe is ready');
  }
  if (status === ConnectorStatus.DISCONNECTED) {
    console.warn('Lost connection to iframe');
  }
});

server.on('message', (event) => {
  if (event.type === ConnectorEventType.GRID_PLACEMENT_CLICKED) {
    console.log('User clicked placement', event.payload.prn);
  }
});

// Push content into the iframe when the editor selects an experience
function sendContentExperience(contentExperience: ContentExperience) {
  server.send({
    type: ConnectorEventType.CONTENT_EXPERIENCE_SEND,
    payload: contentExperience,
  });
}

// Cleanup when unmounting the preview
function destroy() {
  server.teardown();
}

Client (iframe / experience side)

import {
  WindowConnectorClient,
  ConnectorEventType,
} from '@lars-plate/delta-client/connectors';
import { parseDataFromExperienceComponent } from '@lars-plate/delta-client/parsers';
import { environmentEditorUrlMap, Environment } from '@lars-plate/delta-client/api';

const parentOrigin = environmentEditorUrlMap[Environment.PROD];
const parentWindow = window.parent;

const client = new WindowConnectorClient(window, {
  origin: parentOrigin,
  window: parentWindow,
});

client.on('message', (event) => {
  switch (event.type) {
    case ConnectorEventType.CONTENT_EXPERIENCE_SEND: {
      const experience = event.payload;
      const component = experience.experienceComponent;
      const data = parseDataFromExperienceComponent(
        component.buildingBlock,
        component.buildingBlockFieldFulfillments,
      );
      renderExperience(data);
      break;
    }

    case ConnectorEventType.ROOT_EXPERIENCE_COMPONENT_SEND: {
      const component = event.payload;
      // Handle root component updates (e.g. layout shell)
      break;
    }
  }
});

// Notify the CMS when the user interacts with a grid placement
function onPlacementClick(prn: string, experienceComponentPrn: string) {
  client.send({
    type: ConnectorEventType.GRID_PLACEMENT_CLICKED,
    payload: { prn, experienceComponentPrn },
  });
}

function destroy() {
  client.teardown();
}

Message format

Internally, messages use this shape over postMessage:

// Application events
{ type: string; payload: string } // payload is JSON.stringify'd

// Health check (built-in)
{ type: 'HEALTH_CHECK' }
{ type: 'HEALTH_CHECK_RESPONSE' }

Always pass the correct target origin when constructing connectors so both sides reject messages from unexpected origins.


Content parsers

Parsers convert Plate CMS structures into plain objects suitable for templates, React props, or static site generators. Field slugs from the schema become camelCase keys (e.g. hero-title → heroTitle).

There are two families:

| Family | Input | Typical source | |--------|--------|----------------| | GraphQL parsers | ContentItem, BuildingBlock + fulfillments | Connector events, GraphQL API | | Accessible / CDA parsers | CDA JSON (content keyed by slug) | fetchContentItem, CDA experience payloads |

parseContentItem

Maps a GraphQL ContentItem and its contentType.contentFields to { [fieldSlug]: value }. Returns null when contentType.contentFields is missing.

Supported value types include assets, primitives, nested content items, tags, smart text, grid placements, and more. Nested CONTENT_ITEM values are parsed recursively.

import { parseContentItem } from '@lars-plate/delta-client/parsers';
import type { ContentItem } from '@lars-plate/delta-client/graphql';

const contentItem: ContentItem = await fetchContentItemFromApi();

const data = parseContentItem(contentItem);
// Example result:
// {
//   heroTitle: 'Welcome',
//   heroImage: { url: '...', altText: '...', ... },
//   relatedArticles: [{ title: '...' }, { title: '...' }],
// }

parseDataFromExperienceComponent

Maps a GraphQL BuildingBlock plus its BuildingBlockFieldFulfillment[] (from an ExperienceComponent) to the same slug-keyed shape. Use this when rendering from Delta connector events or live preview data.

import { parseDataFromExperienceComponent } from '@lars-plate/delta-client/parsers';
import type { ExperienceComponent } from '@lars-plate/delta-client/graphql';

function componentToProps(component: ExperienceComponent) {
  return parseDataFromExperienceComponent(
    component.buildingBlock,
    component.buildingBlockFieldFulfillments,
  );
}

Accessible (CDA) parsers

CDA payloads already key fields by slug under content. parseDataFromAccessibleExperienceComponent camelCases those keys and recursively parses nested content items.

import {
  parseDataFromAccessibleExperienceComponent,
  parseDependencyTree,
  type AccessibleContentExperience,
} from '@lars-plate/delta-client/parsers';
import type { DeltaApiConfig } from '@lars-plate/delta-client/api';

async function experienceToProps(
  experience: AccessibleContentExperience,
  config: DeltaApiConfig,
) {
  const dependencies = await parseDependencyTree(experience, config);

  return parseDataFromAccessibleExperienceComponent(
    experience.experienceComponent,
    dependencies,
  );
}

| Export | Description | |--------|-------------| | parseDataFromAccessibleExperienceComponent(component, resolvedDependencies?) | CDA experience component → slug-keyed object | | parseDependencyTree(experience, config) | Walk an accessible experience and fetchContentItem for nested items | | parseAccessibleExperienceComponentDependencyTree(component, config) | Same walk starting at one component | | parseAccessibleContentItemDependencyTree(item, config) | Same walk starting at one content item | | AccessibleContentExperience | CDA experience shape (path, experienceComponent, …) | | AccessibleExperienceComponent | CDA component shape (buildingBlockSlug, content, components) | | AccessibleExperienceComponentContent | One CDA field value (value, valueType, buildingBlockFieldPrn) |

If content is missing on an accessible component, parseDataFromAccessibleExperienceComponent returns the component unchanged.

Placeholder mode (insertPlaceholders)

For local development or Storybook, GraphQL parsers can fill required fields with sensible placeholders when values are missing:

import { parseContentItem, type ParseDataConfig } from '@lars-plate/delta-client/parsers';

const config: ParseDataConfig = { insertPlaceholders: true };

const previewData = parseContentItem(partialContentItem, config);
// Required empty STRING → 'Hello World'
// Required empty ASSET → example asset object
// Required nested CONTENT_ITEM → minimal nested structure

When insertPlaceholders is false (default), missing fields are null or [] depending on whether the field allows multiple values.

Array vs single values

Whether a field becomes an array is derived from CMS validation rules (COUNT with max > 1). Single-value fields return one value or null; multi-value fields return an array (possibly empty).


Utils

import { isPathPart, isGridPlacement } from '@lars-plate/delta-client/utils';

if (isPathPart(link)) {
  // link is a GraphQL PathPart
}

if (isGridPlacement(link)) {
  // link is a GraphQL GridPlacement
}

Both guards inspect the resource type in the entity’s PRN (path-part vs grid-placement). Plain strings are not treated as either.


GraphQL types

The ./graphql export re-exports TypeScript types generated from the Plate GraphQL schema (e.g. ContentExperience, ExperienceComponent, ContentItem, BuildingBlock, Asset, enums like TagVisibility).

Use these types when:

  • Typing connector event payloads
  • Typing GraphQL parser inputs
  • Sharing shapes with your own GraphQL client (graphql-request, Apollo, etc.)
import type {
  ContentExperience,
  ExperienceComponent,
  ContentItem,
  BuildingBlockFieldFulfillment,
} from '@lars-plate/delta-client/graphql';

async function loadExperience(prn: string): Promise<ContentExperience> {
  // Your GraphQL query here — types align with generated definitions
  throw new Error('implement with your API client');
}

This package does not ship GraphQL operations. For published content, prefer the Content Delivery API. For editor/preview payloads, use the window connectors.


End-to-end example

A minimal experience app inside an iframe that renders CMS content and reports grid clicks:

import { WindowConnectorClient, ConnectorEventType } from '@lars-plate/delta-client/connectors';
import { parseDataFromExperienceComponent } from '@lars-plate/delta-client/parsers';
import { environmentEditorUrlMap, Environment } from '@lars-plate/delta-client/api';

const CMS_ORIGIN = environmentEditorUrlMap[Environment.PROD];

const client = new WindowConnectorClient(window, {
  origin: CMS_ORIGIN,
  window: window.parent,
});

client.on('message', (event) => {
  if (event.type !== ConnectorEventType.CONTENT_EXPERIENCE_SEND) return;

  const { experienceComponent } = event.payload;
  const props = parseDataFromExperienceComponent(
    experienceComponent.buildingBlock,
    experienceComponent.buildingBlockFieldFulfillments,
  );

  document.getElementById('app')!.textContent = JSON.stringify(props, null, 2);
});

document.querySelectorAll('[data-grid-placement]').forEach((el) => {
  el.addEventListener('click', () => {
    client.send({
      type: ConnectorEventType.GRID_PLACEMENT_CLICKED,
      payload: {
        prn: el.getAttribute('data-prn')!,
        experienceComponentPrn: el.getAttribute('data-component-prn')!,
      },
    });
  });
});

API reference (summary)

Connectors

| Export | Description | |--------|-------------| | WindowConnectorClient | Iframe-side connector; send(), on('message'), teardown() | | WindowConnectorServer | Parent-side connector; setClient(), connect(), send(), on('message' \| 'status_changed'), teardown() | | ConnectorEventType | Enum of event type strings | | ConnectorStatus | Connection lifecycle enum | | ConnectorEventOption | Union of all typed connector events | | StatusChangedEvent | { status: ConnectorStatus } |

API

| Export | Description | |--------|-------------| | fetchContentExperienceByPath(path, config?) | GET …/content-experiences/path{path} → Response | | fetchContentExperienceByPrn(prn, config?) | GET …/content-experiences/{prn} → Response | | fetchContentExperiences(input?, config?) | Paginated experiences | | fetchContentItem(prn, config?) | Single content item (parsed accessible payload) | | fetchContentItems(input?, config?) | Paginated content items | | fetchTags(input?, config?) | Paginated tags | | DeltaApiConfig | { token?, version?, environment? } | | Environment / Version | CDA stack and URL version enums | | environmentBaseUrlMap / environmentEditorUrlMap | CDA and editor origins | | PaginatedResponse<T> | { entities, meta.pagination, links } | | ContentExperienceDto / ExperienceComponentDto / ContentItemDto / TagDto | List-endpoint entity shapes | | QueryContentExperiencesInput / QueryContentItemsInput / QueryTagsInput | List filters |

Parsers

| Export | Description | |--------|-------------| | parseContentItem(contentItem, config?) | GraphQL content item → slug-keyed object, or null | | parseDataFromExperienceComponent(buildingBlock, fulfillments, config?) | GraphQL experience component data → slug-keyed object | | parseDataFromAccessibleExperienceComponent(component, dependencies?) | CDA experience component → slug-keyed object | | parseDependencyTree(experience, config) | Resolve nested CDA content-item dependencies | | ParseDataConfig | { insertPlaceholders?: boolean } | | defaultParseDataConfig | { insertPlaceholders: false } | | AccessibleContentExperience / AccessibleExperienceComponent | CDA TypeScript shapes |

Utils

| Export | Description | |--------|-------------| | isPathPart(link) | true when link.prn is a path-part | | isGridPlacement(link) | true when link.prn is a grid-placement |

GraphQL

| Export | Description | |--------|-------------| | * from @lars-plate/delta-client/graphql | Generated schema types (see src/graphql/generated.ts) |


Development

# Install dependencies (monorepo root)
pnpm install

# Build this library (TypeScript + Vite → dist/)
pnpm nx build delta-client

# Run unit tests
pnpm nx test delta-client

Build output is written to dist/ with separate entry points matching package.json exports.


License

MIT © Lars Baalmans