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

@arche-cms/sdk

v0.1.14

Published

Readme

@arche-cms/sdk

TypeScript client SDK for the Arche CMS API. Provides a fully typed HTTP client for interacting with any Arche CMS instance.

Installation

pnpm add @arche-cms/sdk

Quick Start

import { createClient } from "@arche-cms/sdk";

const client = createClient({
  baseUrl: "https://cms.example.com",
  token: "your-api-token", // optional
});

Collections

// Type the client with your collection schema
interface Post {
  id: string;
  title: string;
  slug: string;
  content: string;
  status: "draft" | "published";
}

const posts = client.collection<Post>("posts");

// List with pagination
const { data, total } = await posts.list({ limit: 10, offset: 0 });

// Get by ID
const post = await posts.get("1");

// Create
const created = await posts.create({ title: "Hello", slug: "hello" });

// Update
const updated = await posts.update("1", { title: "Updated" });

// Delete
await posts.delete("1");

// Bulk operations
await posts.bulkDelete(["1", "2", "3"]);

// Publishing
await posts.publish("1");
await posts.unpublish("1");

// Soft delete restore
await posts.restore("1");

// Version history
const { data: versions } = await posts.versions("1");
await posts.restoreVersion("1", "v1");

Query Parameters

const { data, total } = await posts.list({
  limit: 25,
  offset: 0,
  sort: "title:asc",
  select: ["title", "slug"],
  populate: ["author"],
  locale: "en",
  where: { status: "published" },
});

Globals

interface SiteSettings {
  siteName: string;
  description: string;
}

const settings = client.global<SiteSettings>("site-settings");

const data = await settings.get();
const updated = await settings.upsert({ siteName: "My Blog" });

Auth

// Login
const { user, accessToken, refreshToken } = await client.auth.login(
  "[email protected]",
  "password",
);

// Register
await client.auth.register("[email protected]", "password");

// Refresh tokens
await client.auth.refresh(refreshToken);

// Get current user
const me = await client.auth.me();

// Password reset
await client.auth.forgotPassword("[email protected]");
await client.auth.resetPassword("token", "newPassword");

// Setup status
const { hasAdmin } = await client.auth.setupStatus();

Media

// List media files
const { data: files } = await client.media.list({ limit: 10 });

// Upload (base64)
const uploaded = await client.media.upload({
  fileName: "image.png",
  mimeType: "image/png",
  data: "base64-encoded-data",
  alt: "Description",
});

// Get metadata
const file = await client.media.get("1");

// Delete
await client.media.delete("1");

// Media folders
const { data: folders } = await client.media.folders.list();
await client.media.folders.create({ name: "Images" });

Users & Roles

// Users
const { data: users } = await client.users.list();
const user = await client.users.create({ email: "[email protected]", password: "pass" });
await client.users.update("1", { role: "admin" });
await client.users.delete("1");

// Roles
const { data: roles } = await client.roles.list();
const role = await client.roles.create({
  name: "Editor",
  permissions: [{ action: "read", resource: "posts" }],
});
await client.roles.delete("1");

Settings (API Tokens & Webhooks)

// API Tokens
const { data: tokens } = await client.settings.apiTokens.list();
const { rawToken } = await client.settings.apiTokens.create({ name: "My Token" });
await client.settings.apiTokens.delete("1");

// Webhooks
const { data: hooks } = await client.settings.webhooks.list();
await client.settings.webhooks.create({
  name: "Notify",
  url: "https://example.com/hook",
  events: ["collection:created", "collection:updated"],
});
await client.settings.webhooks.update("1", { enabled: false });
await client.settings.webhooks.delete("1");

Activity

const { data: entries } = await client.activity.list({
  action: "create",
  collection: "posts",
  limit: 50,
});

Error Handling

import { ApiError } from "@arche-cms/sdk";

try {
  await client.collection("posts").get("nonexistent");
} catch (error) {
  if (error instanceof ApiError) {
    console.log(error.status); // 404
    console.log(error.message); // "Not found"
    console.log(error.code); // "NOT_FOUND"
    console.log(error.details); // [{ path: [...], message: "..." }]
  }
}

Authentication

The SDK supports two authentication methods:

API Token

const client = createClient({
  baseUrl: "https://cms.example.com",
  token: "cms_your-api-token",
});

JWT (via Auth Client)

const client = createClient({ baseUrl: "https://cms.example.com" });
const { accessToken } = await client.auth.login("[email protected]", "password");
client.setToken(accessToken);

Custom Fetch

Use a custom fetch implementation for Node.js, testing, or alternative runtimes:

import { createClient } from "@arche-cms/sdk";
import nodeFetch from "node-fetch";

const client = createClient({
  baseUrl: "https://cms.example.com",
  token: "cms_token",
  fetch: nodeFetch as typeof globalThis.fetch,
});

License

MIT