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

@datocms/cma-client-analysis

v5.4.14

Published

TypeScript-based static analysis utilities for the @datocms/cma-client-node Client class. Extracts method signatures, referenced types, and endpoint mappings.

Readme

Node.js CI

DatoCMS CMA Client Analysis

Static-analysis utilities for @datocms/cma-client-node, built on the TypeScript Compiler API. Inspects the Client class to extract method signatures, resolve referenced types, and produce ready-to-render TypeScript snippets — useful for generating API reference docs, AI tooling, or any introspection of the CMA client surface.

Installation

npm install @datocms/cma-client-analysis @datocms/cma-client-node @datocms/rest-api-reference typescript

@datocms/cma-client-node, @datocms/rest-api-reference, and typescript are peer dependencies — the package introspects whichever versions of them are installed in your tree, so the output is always in sync with the client you actually run.

Usage

import {
  getCmaClientProgram,
  extractAllMethodNames,
  extractMethodSignature,
  extractResourcesEndpointMethods,
  extractTypeDependencies,
} from '@datocms/cma-client-analysis';

// Build a TypeScript program over @datocms/cma-client-node's .d.ts entry.
// Expensive (~hundreds of ms): build once, thread through every extract* call.
const { program, checker, clientClass } = getCmaClientProgram();

// All method names available on a resource.
extractAllMethodNames(checker, clientClass, 'items');
// → ['list', 'find', 'create', 'rawList', 'rawFind', 'rawCreate', ...]

// Full signature for one method, including referenced type symbols.
const signature = extractMethodSignature(checker, clientClass, 'items', 'create');
// → { methodName, parameters, returnType, referencedTypeSymbols, ... }

// All client methods that implement a given REST endpoint, matched by docUrl.
import { findResourcesEntityByNamespace, findResourcesEndpointByRel, parseResourcesSchema } from '@datocms/rest-api-reference';
import resourcesJson from '@datocms/cma-client/resources.json';

const resourcesSchema = parseResourcesSchema(resourcesJson);
const entity = findResourcesEntityByNamespace(resourcesSchema, 'menuItems');
const endpoint = findResourcesEndpointByRel(entity!, 'create');

const methods = extractResourcesEndpointMethods(checker, clientClass, endpoint!);
// → [
//     { name: 'create',    functionDefinition: 'create(body: MenuItemCreateSchema): Promise<MenuItem>',                  referencedTypes: Set { ... } },
//     { name: 'rawCreate', functionDefinition: 'rawCreate(body: MenuItemCreateSchema): Promise<MenuItemCreateTargetSchema>', referencedTypes: Set { ... } },
//   ]

// Inline TypeScript declarations for a set of referenced types, walking up to a depth.
const { expandedTypes, notExpandedTypes } = extractTypeDependencies(
  checker,
  program,
  Array.from(signature!.referencedTypeSymbols.keys()),
  signature!.referencedTypeSymbols,
  { maxDepth: 2 },
);

Caching

getCmaClientProgram() is not cached — every call rebuilds the program. The cost (parsing the full client .d.ts graph) is non-trivial, so:

  • One-shot processes (CLIs, scripts): call once at startup, thread the result through.
  • Long-running processes (servers, MCP): wrap the call in your own memoization.

This keeps the lifetime decision in the consumer's hands instead of pinning it to module-level state.