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

@42ch/spoke-operations

v0.11.1

Published

SPOKE lifecycle operations — pure helpers over wire types

Downloads

2,004

Readme

@42ch/spoke-operations

Hand-written TypeScript lifecycle helpers for SPOKE: extension merge/preserve, Finding status transitions, promote acceptance gates, Scope/upsert/relate validators, body.attributes read helpers, timeline sequence helpers, AssemblePacket builders, capability-sliced adapter ports, and injection orchestration.

Depends on @42ch/spoke-schemas for wire types. Behavioral parity with the Rust crate spoke-operations.

Install

pnpm add @42ch/spoke-schemas @42ch/spoke-operations
# Pin both to the same lockstep SemVer (e.g. @X.Y.Z)

Pin both packages to the same lockstep SemVer.

Usage — pure helpers

import type { PromoteRequest } from "@42ch/spoke-schemas";
import {
  validatePromoteRequest,
  applyPromoteAcceptance,
  buildAssemblePacket,
  transitionFindingStatus,
  mergeExtensionMaps,
  SpokeRejectCode,
} from "@42ch/spoke-operations";

const request: PromoteRequest = { candidate /* KnowledgeEntry */ };
const gate = validatePromoteRequest(request);

if (gate.ok) {
  const accepted = applyPromoteAcceptance(request);
  // Persist via your product adapter
} else {
  console.error(gate.code, gate.message); // e.g. SpokeRejectCode.CANDIDATE_NOT_PROVISIONAL
}

Usage — adapter ports and orchestration

Implement capability-sliced ports (KnowledgeEntryPort, RelationPort, ScopeQueryPort, FindingPort, RuleQueryPort, HostManifestPort, plus optional ComputablePort / ForkTimelineQueryPort) on one adapter type. Ergonomic composed-port aliases (BaselineAdapter, ComputableAdapter, ForkAdapter, FullAdapter) name the same intersections as BaselinePorts, ComputablePorts, ForkPorts, and FullPorts. Then call the matching orchestrator:

import type { CheckRequest, UpsertRequest } from "@42ch/spoke-schemas";
import {
  orchestrateUpsert,
  orchestrateCheck,
  spokeOk,
  type BaselinePorts,
  type CheckRunInput,
} from "@42ch/spoke-operations";

declare const ports: BaselinePorts;
declare const upsertRequest: UpsertRequest;
declare const checkRequest: CheckRequest;

async function runBaseline() {
  const upserted = await orchestrateUpsert(ports, upsertRequest);

  const checked = await orchestrateCheck(ports, checkRequest, (_input: CheckRunInput) => {
    // Product-owned checker; library loads scope data and persists findings via ports
    return spokeOk([]);
  });
}

Optional capabilities use the composed port types (ComputablePorts, ForkPorts) with orchestrateProject / orchestrateCompute and orchestrateForkCheck / orchestrateForkAssemble.

Integrator notes

  • Adapters own transaction boundaries for multi-entry upsert and other multi-write sequences.
  • Active-uniqueness helpers take caller-supplied peer sets. Orchestration supplies batch-local peers; pass a store-wide snapshot when product uniqueness must span the whole store.
  • Absent optional ports at a dynamic boundary surface SpokeRejectCode.CAPABILITY_PORT_MISSING. HostManifestPort is baseline-required — not gated behind that code.

Helper families

  • SpokeResult / SpokeReject / SpokeRejectCode — unified reject envelope (stable code strings shared with Rust)
  • mergeExtensionMaps, preserveExtensionMaps
  • isValidFindingStatusTransition, transitionFindingStatus
  • validatePromoteRequest, applyPromoteAcceptance
  • knowledgeEntryToAssembleEntry, buildAssemblePacket
  • Scope matchers, OCC revision assert, KnowledgeEntry status/uniqueness, upsert/relate gates, computable validators, validateMindState (wire-shape gate for the optional l5-mind capability)
  • listBodyAttributes, filterBodyAttributesByTraitType, findBodyAttribute — read/filter body.attributes by trait_type
  • filterTimelineEventsByMomentScale, orderTimelineEventsByIds, orderTimelineEventsByPrecedes — filter and order moment-scale TimelineEvents from caller-supplied sets
  • Adapter ports + orchestration: KnowledgeEntryPortHostManifestPortFullAdapter, CheckRunInput, orchestrateUpsertorchestrateForkAssemble

Reference FullAdapter implementation: fixtures/toy-world/ (ToyWorldAdapter in TypeScript src/adapter/).

Helpers and orchestrators are pure relative to host I/O — all reads and writes go through injected ports. Normative behavior: spoke-operations.md.