Registry / storage / ipld-schema

ipld-schema

JSON →
library3.0.3jsnpmunverified

IPLD Schema DSL parser and CLI utilities for JavaScript. Provides parse, print, and validation functions for IPLD schema definitions. Current stable version is 3.0.3, with semiver releases as needed. Key differentiators: pure JS, no native dependencies, supports both programmatic use and CLI (validate and to-json commands), handles .ipldsch and .md files, and is part of the broader IPLD ecosystem. Ships TypeScript types.

npm install ipld-schema
INSTALL
IMPORT
SIG · IPLD-SCHEMA
I
ipld-schema
storagejavascriptv3.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
import { parse } from 'ipld-schema'
const { parse } = require('ipld-schema')
This package is ESM-only since v3. CommonJS require() will fail unless using a dynamic import.
print
import { print } from 'ipld-schema/print.js'
import { print } from 'ipld-schema'
print is not re-exported from the main entry; it must be imported from the subpath 'ipld-schema/print.js'.
validate
import { validate } from 'ipld-schema'
import { validateSchema } from 'ipld-schema'
The function is named validate, not validateSchema. It validates schema DSL and returns an object with errors and warnings.
IPLDSchema (type)
import type { IPLDSchema } from 'ipld-schema'
import { IPLDSchema } from 'ipld-schema'
IPLDSchema is a TypeScript type export; use `import type` to avoid runtime inclusion.

Parses an IPLD schema DSL string into an AST and validates it for correctness. Uses the parse and validate functions from the main module.

import { parse, validate } from 'ipld-schema'; const schemaDSL = ` type Person struct { name String age Int } `; // Parse schema DSL to AST const schema = parse(schemaDSL); console.log(JSON.stringify(schema, null, 2)); // Output includes field types and representation details // Validate schema DSL (check for errors) const result = validate(schemaDSL); if (result.errors.length === 0) { console.log('Schema is valid'); } else { console.error('Schema errors:', result.errors); }
Debug
Known issues
breakingPackage is ESM-only since v3. If using CommonJS (require), you must use dynamic import or upgrade to Node >= 16.
fix
Use import syntax or dynamic import() instead of require().
affects: >=3.0.0
deprecatedThe 'print' function is not exported from the main entry point; it must be imported from 'ipld-schema/print.js'. In older versions (v2), print was exported from the main entry.
fix
Change import path to 'ipld-schema/print.js'.
affects: >=3.0.0
gotchaThe CLI executable may not be available if installed as a dependency in a project without global install. Use npx ipld-schema or script with node_modules/.bin/ipld-schema.
fix
Use npx ipld-schema or add a script to package.json.
affects: *
gotchaSchema parsing does not perform recursive type resolution; it only parses the given DSL string. For validation of data against a schema, use ipld-schema-validator.
fix
Use ipld-schema-validator package for data validation.
affects: *
Errors
Common errors & fixes
SyntaxError: Unexpected token 'export'
Using CommonJS require() on an ESM-only module (v3+).
fix
Use 'import { parse } from 'ipld-schema'' or 'const { parse } = await import('ipld-schema')'.
ERR_MODULE_NOT_FOUND: Cannot find module 'ipld-schema/print'
Missing .js extension in subpath import. Module resolution requires explicit extension for local imports.
fix
Use 'import { print } from 'ipld-schema/print.js'' with the '.js' extension.
TypeError: parse is not a function
Using default import instead of named import; the package has no default export.
fix
Use 'import { parse } from 'ipld-schema'' instead of 'import parse from 'ipld-schema''.
Upgrade
Version history
3.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
14
Resources
ipld-schema — npm install ipld-schema · libregistry