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

@modulacms/types

v0.1.1

Published

Shared TypeScript types for ModulaCMS SDKs

Readme

@modulacms/types

Shared TypeScript type definitions for the ModulaCMS SDK ecosystem. This package provides branded ID types, entity interfaces, enums, pagination, and error types consumed by both @modulacms/sdk (content delivery) and @modulacms/admin-sdk (admin CRUD).

Install

npm install @modulacms/types
# or
pnpm add @modulacms/types

Usage

import type {
  ContentID,
  UserID,
  ContentData,
  Field,
  PaginatedResponse,
  ApiError,
} from '@modulacms/types'

import { isApiError, CONTENT_FORMATS } from '@modulacms/types'

What's included

Branded ID types

All entity identifiers are nominal (branded) string types. Two values with the same underlying string but different brands are not assignable to each other, catching misuse at compile time.

import type { ContentID, UserID } from '@modulacms/types'

const contentId = '01HXK4N2F8QZJV3K7M1Y9ABCDE' as ContentID
const userId = '01HXK4N2F8QZJV3K7M1Y9ABCDE' as UserID

// contentId = userId  // compile error -- different brands

Available ID types:

| Type | Entity | |------|--------| | UserID | User account | | ContentID | Public content node | | ContentFieldID | Public content field value | | ContentRelationID | Public content relation | | DatatypeID | Datatype (schema) definition | | FieldID | Field (schema) definition | | MediaID | Media asset | | RoleID | User role | | PermissionID | Permission | | RolePermissionID | Role-permission junction | | RouteID | Public route | | SessionID | Active session | | UserOauthID | User OAuth connection | | AdminContentID | Admin content node | | AdminContentFieldID | Admin content field value | | AdminContentRelationID | Admin content relation | | AdminDatatypeID | Admin datatype definition | | AdminFieldID | Admin field definition | | AdminRouteID | Admin route |

Branded value types: Slug, Email, URL.

The Brand<T, B> utility type is also exported for creating custom branded types.

Enums

import type { ContentStatus, FieldType, ContentFormat } from '@modulacms/types'
import { CONTENT_FORMATS } from '@modulacms/types'

ContentStatus -- 'draft' | 'published' | 'archived' | 'pending'

FieldType -- 'text' | 'textarea' | 'number' | 'date' | 'datetime' | 'boolean' | 'select' | 'media' | 'relation' | 'json' | 'richtext' | 'slug' | 'email' | 'url'

ContentFormat -- 'contentful' | 'sanity' | 'strapi' | 'wordpress' | 'clean' | 'raw'

CONTENT_FORMATS is a runtime as const array for validating format strings.

Entity types

Content -- ContentData, ContentField, ContentRelation

Content nodes form a linked-list tree using parent_id, first_child_id, next_sibling_id, and prev_sibling_id pointers for O(1) navigation and reordering.

Schema -- Datatype, Field, DatatypeField

Datatypes define content categories. Fields define individual data entries within a datatype. DatatypeField is the junction record linking them with sort order.

Media -- Media, MediaDimension

Media assets with support for responsive srcset and dimension presets.

Routing -- Route

Maps URL slugs to content trees.

Tree -- NodeDatatype, NodeField, ContentNode, ContentTree

The assembled hierarchical content tree returned by slug-based content delivery. ContentTree contains a root ContentNode, which recursively nests child nodes, each with their datatype definition, content instance data, and field values.

Pagination

import type { PaginationParams, PaginatedResponse } from '@modulacms/types'

const params: PaginationParams = { limit: 20, offset: 0 }
// PaginatedResponse<T> = { data: T[], total: number, limit: number, offset: number }

Error handling

import type { ApiError } from '@modulacms/types'
import { isApiError } from '@modulacms/types'

try {
  await client.content.get(id)
} catch (err) {
  if (isApiError(err)) {
    console.error(`API ${err.status}: ${err.message}`)
  }
}

ApiError has a _tag: 'ApiError' discriminant to distinguish API errors from network-level failures.

Request options

import type { RequestOptions } from '@modulacms/types'

// Pass to any SDK method for per-request configuration
const options: RequestOptions = { signal: AbortSignal.timeout(5000) }

Common primitives

ULID -- string alias for ULID identifiers. Timestamp -- ISO 8601 UTC timestamp string. NullableString, NullableNumber -- nullable variants for optional API fields.

Build

Dual ESM + CJS output via tsup. TypeScript declarations are included.

pnpm build       # Build to dist/
pnpm typecheck   # Type-check without emitting
pnpm clean        # Remove build artifacts

License

MIT