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

@codama/upgrade

v1.0.0

Published

Upgrade Codama IDLs to the latest major version of the standard

Readme

Codama ➤ Upgrade

npm npm-downloads

This package upgrades Codama IDLs of any supported major version to the latest major version of the standard.

Installation

pnpm install @codama/upgrade

[!NOTE] This package is not included in the main codama package, so the core stays lean. Add it at the boundary where your tooling ingests IDLs of unknown or older versions.

Functions

upgrade(rootNode)

This function takes a RootNode of any supported major version and returns a RootNode conforming to the latest major, restamped with the latest spec version.

import { upgrade } from '@codama/upgrade';
import { createFromRoot } from 'codama';

const codama = createFromRoot(upgrade(rootNodeOfAnyVersion));

IDLs already on the latest major go through unchanged, minus the version restamp. IDLs that predate the 1.0.0 specification throw a CODAMA_ERROR__UNSUPPORTED_VERSION error and must be regenerated from their original source; IDLs from a future major throw a CODAMA_ERROR__VERSION_MISMATCH error and require updating your Codama dependencies instead.

upgradeFromJson(json)

This function wraps upgrade for JSON-encoded IDLs, e.g. when reading an IDL from disk or from the chain.

import { upgradeFromJson } from '@codama/upgrade';
import { createFromRoot } from 'codama';
import { readFileSync } from 'node:fs';

const json = readFileSync('idl.json', 'utf-8');
const codama = createFromRoot(upgradeFromJson(json));

upgradeToLatestVisitor()

This function returns a visitor that upgrades the visited IDL, designed as a preprocessing step at IDL-ingestion boundaries. It is also the package's default export, so it can be used as a before visitor in a Codama CLI config using the bare module name, ensuring any older IDL is upgraded before other visitors and scripts run:

{
    "idl": "program/idl.json",
    "before": ["@codama/upgrade"]
}

The explicit "@codama/upgrade#upgradeToLatestVisitor" form is equivalent.

How it works

The package maintains an append-only chain of pure, hand-written functions, each upgrading exactly one major to the next. Upgrading detects the IDL's source major from its version attribute, runs every function from that major up to the latest, and restamps the result — so supporting a new major only ever requires one new function, and every older version reaches the latest for free, forever.

The node types of older majors are frozen into this package at the time each major is superseded (generated from a pinned @codama/spec of that era and committed). They are exposed as type-only namespaces for anyone writing custom migration logic:

import type { v1 } from '@codama/upgrade';

function inspectLegacyIdl(root: v1.RootNode) {
    // Typed against the frozen v1 node types.
}

Upgrade functions are pure JSON-tree-in, JSON-tree-out transforms with no environment access, which keeps the upgrade chain portable to other implementations of the Codama standard.

Maintainers: the playbook for releasing a new major of the Codama standard lives in the repository-root CONTRIBUTING.