Skip to content

Package exports map

json-tology ships nine exports subpaths. Each subpath is a separate entry point with its own import condition and .d.ts. Tree-shaking works at the subpath boundary — importing from json-tology/types does not pull in the runtime classes from json-tology, and vice versa.

Subpath reference

json-tology (root — .)

The main runtime entry. Exports:

  • JsonTology — the facade class: JsonTology.create, instantiate, validate, is, materialize, set, dump, ontology, encode, addComputed, addInvariant, and more.
  • Compose — schema derivation combinators: extend, pick, omit, partial, required, intersection, discriminatedUnion, equivalent, subClassOf, restrictions, and more.
  • Transform — transform registration: Transform.create, Transform.brand, Transform.chain, Transform.getDecoder.
  • All error classesBaseError, SchemaError, GraphError, InstantiationError, MaterializationError, CoercionError, DecodeError, EncodeError, TransformError, OwlImportError, ValidationErrors.
  • Error-code constantsSCHEMA_ERROR_CODE, GRAPH_ERROR_CODE, INSTANTIATION_ERROR_CODE, MATERIALIZATION_ERROR_CODE, COERCION_ERROR_CODE, TRANSFORM_ERROR_CODE, OWL_IMPORT_ERROR_CODE. Import these to compare error.code without using magic strings.
  • Runtime utilities: AboxGraph, GraphEngine, Hash, Curie, Value, Changeset, Operations, Path, Resolver, Lift, Materializer, OntologyBuilder, GraphOntologySerializer, Loaders.

What is NOT in the root entry: type aliases, interface contracts, and type-only utilities. These live behind json-tology/types and json-tology/interfaces respectively. This is by design — see below.

ts
import { JsonTology, Compose, Transform } from 'json-tology';
import { InstantiationError, SCHEMA_ERROR_CODE } from 'json-tology';

json-tology/value

Value utilities and data-operation primitives for consumers who do not need the full registry. Exports:

  • Value, Changeset, Operations, Hash
ts
import { Value, Operations, Hash } from 'json-tology/value';

json-tology/schema

Schema registration and composition without the graph or ontology modules. Exports:

  • Compose, SchemaRegistry, FormatRegistry, Transform

Use this entry when you want the authoring and validation surface but do not need OWL/SHACL output or ABox projection.

ts
import { Compose, SchemaRegistry } from 'json-tology/schema';

json-tology/ontology

Ontology serialization and graph utilities. Exports:

  • GraphOntologySerializer, GraphShaclSerializer, GraphSchemaSerializer, OntologyBuilder
ts
import { OntologyBuilder } from 'json-tology/ontology';

json-tology/types

Type aliases and compile-time utilities. This subpath is types-only — it emits no runtime JavaScript. Exports every type alias and compile-time type declared in src/types/:

  • InferType<T>, InferSchemaType<T, TRoot, TRefs>, ParseOutputType<T>, MaterializedSchemaType<T>, LooseInputType<T>, SchemaReferencesMapType<T>, SchemaMapFromTupleType<T>
  • Branded primitive types, constraint brands (MinLength, Pattern, etc.), Brand<T, Tag>
  • JsonTologyTypeConfigInterface for module augmentation (brand-disable configuration)
ts
import type { InferType, SchemaReferencesMapType } from 'json-tology/types';

json-tology/interfaces

Interface contracts. This subpath is types-only — zero runtime output. Exports every interface declared in src/interfaces/:

  • SubClassOfSchemaInterface, ComposeInterface, CompositionAccumulatorInterface
  • GraphEngineInterface, MaterializerInterface, SchemaRegistryInterface
  • ValueInterface, CurieInterface, ChangesetInterface
  • LoggerInterface, InvariantInterface, FormatRegistryInterface
  • All other interface contracts used in the public API
ts
import type { SubClassOfSchemaInterface } from 'json-tology/interfaces';
import type { MaterializerInterface } from 'json-tology/interfaces';

json-tology/viz

HTML renderer and visualization utilities. Exports HtmlRenderer, VizDataCollector, TypeStringEmitter. Used by the runnable documentation examples.

ts
import { HtmlRenderer } from 'json-tology/viz';

json-tology/owl-gen

Browser-safe programmatic API for OWL TBox → TypeScript codegen. Returns generated source as strings; performs no file I/O. Exports generateFromTbox, generateRegistryDirectory.

ts
import { generateFromTbox } from 'json-tology/owl-gen';
const source = generateFromTbox({ input: myJsonLd, name: 'bookstore' });

json-tology/owl-gen-node

Node-only file-writing wrapper over json-tology/owl-gen. Adds writeFromTbox and writeRegistryDirectory which write the generated source to disk. Import from build scripts and CLI tooling only.

ts
import { writeFromTbox } from 'json-tology/owl-gen-node';
writeFromTbox({ input: myJsonLd, name: 'bookstore', output: './src/bookstore-registry.ts' });

Why interface contracts and type aliases are on subpaths, not the root

The root entry (json-tology) exports only runtime classes and error codes. Interface contracts (json-tology/interfaces) and type aliases (json-tology/types) are deliberately on separate subpaths.

The comment at the top of src/index.ts states the reason:

Type aliases live behind json-tology/types; interface contracts live behind json-tology/interfaces. Importing those from this top-level entry is forbidden — it forces consumers' bundlers to pull the entire type graph when they only wanted the runtime, and it invites circular import cycles when internal modules look up to the package root for a single type.

This means import type { SubClassOfSchemaInterface } from 'json-tology/interfaces' is the intended import, not a workaround. The same applies to InferType, InferSchemaType, and every other type alias — they live in json-tology/types.

ts
// CORRECT — the intended import paths
import { JsonTology, Compose } from 'json-tology';
import type { InferType } from 'json-tology/types';
import type { SubClassOfSchemaInterface } from 'json-tology/interfaces';

// INCORRECT — SubClassOfSchemaInterface is not in the root barrel
// import type { SubClassOfSchemaInterface } from 'json-tology'; // compile error

Since both json-tology/interfaces and json-tology/types are type-only exports, they add no weight to your bundle and no runtime module to your graph. The subpath separation exists to keep internal import topologies acyclic and to let bundlers tree-shake the runtime classes cleanly without the full type graph attached.


Quick reference

SubpathRuntime codeWhat you get
json-tologyYesJsonTology, Compose, Transform, error classes, error codes
json-tology/valueYesValue, Changeset, Operations, Hash
json-tology/schemaYesCompose, SchemaRegistry, FormatRegistry, Transform
json-tology/ontologyYesSerializers, OntologyBuilder
json-tology/typesNo (types only)InferType, InferSchemaType, constraint brands, SchemaReferencesMapType
json-tology/interfacesNo (types only)SubClassOfSchemaInterface, MaterializerInterface, all interface contracts
json-tology/vizYesHtmlRenderer, VizDataCollector, TypeStringEmitter
json-tology/owl-genYesgenerateFromTbox, generateRegistryDirectory (browser-safe)
json-tology/owl-gen-nodeYeswriteFromTbox, writeRegistryDirectory (Node.js, disk I/O)

Released under the MIT License.