capdag
v1.255.27
Published
JavaScript implementation of Cap URN (Capability Uniform Resource Names) with strict validation and matching
Maintainers
Readme
CapDAG for JavaScript
This public package is CapDAG's JavaScript planning and notation mirror. Use it in browsers or Node.js for Tagged, Media, and Cap URNs, capability definitions, dispatch, Machine Notation, planning, and graph rendering.
JavaScript intentionally does not implement the cartridge runtime, host, relay, or Bifaci process surface. That boundary is part of the package design, not an unreported parity gap. Rust remains the behavioral reference for shared features.
Install the package
npm install capdagNode.js 14 or newer is required by the package manifest.
Parse and build Cap URNs
const { CapUrn, CapUrnBuilder } = require("capdag");
const parsed = CapUrn.fromString(
'cap:disbind;in="media:ext=pdf";out="media:enc=utf-8;page"'
);
const built = new CapUrnBuilder()
.inSpec("media:ext=pdf")
.outSpec("media:enc=utf-8;page")
.marker("disbind")
.build();
console.log(parsed.toString() === built.toString());Treat URNs as opaque parsed values. Use the package's predicates for equivalence, conformance, dispatch, and ranking instead of string surgery.
Find the relevant API
capdag.jsprovides URNs, definitions, dispatch, and matching.machine-parser.jsis generated frommachine.pegjs.planner.jsprovides planning and Machine Notation structures.cap-fab-renderer.jsand the browser build support graph presentation.RULES.mdrecords package-specific construction rules.
The normative semantics and terminology live in the CapDAG specification. Source comments and exports are the JavaScript API reference.
Build and verify changes
npm run build:parser
npm testnpm test runs the parser build first. Shared behavior changes require the
applicable reference test with the same substantive number and assertions.
License
MIT
