@graphmd/dataset
v0.13.1
Published
The `@graphmd/dataset` package is the **canonical home for GraphMD dataset semantics**. It contains the parsing, validation, hashing, and canonicalization logic that defines what a GraphMD dataset means. Other packages (including the legacy `packages/core
Downloads
317
Readme
@graphmd/dataset
The @graphmd/dataset package is the canonical home for GraphMD dataset semantics. It contains the parsing, validation, hashing, and canonicalization logic that defines what a GraphMD dataset means. Other packages (including the legacy packages/core wrapper) should treat this as the authoritative implementation.
Install
npm install @graphmd/datasetUsage
Validate a snapshot
import { validateDatasetSnapshot } from '@graphmd/dataset';
const snapshot = {
files: new Map([
['types/book.md', new TextEncoder().encode('---\ntypeId: book\nfields: {}\n---\n')],
]),
};
const result = validateDatasetSnapshot(snapshot);
if (!result.ok) {
console.error(result.errors);
}Compute a dataset hash
import { computeGdHashV1 } from '@graphmd/dataset';
const result = computeGdHashV1(snapshot, 'snapshot');
if (result.ok) {
console.log(result.cid);
}Canonicalize a snapshot
import { canonicalizeDatasetSnapshot } from '@graphmd/dataset';
const canonical = canonicalizeDatasetSnapshot(snapshot);API surface
The public API is defined by the barrel export in src/index.ts. Use that file as the canonical map of exported functions and types.
Development
# Build ESM + CJS outputs
npm --workspace packages/dataset run build
# Run tests
npm --workspace packages/dataset test
# Typecheck
npm --workspace packages/dataset run typecheck