TypeScript SDK

TypeScript types and API client for INHERIT estate documents. Full type coverage for 100+ entity types with auto-generated API client stubs.

TypeScript v6.0.02 min read
Package: @openinherit/sdk

Installation#

bash
npm install @openinherit/sdk

The SDK requires a peer dependency for HTTP client support:

bash
npm install @hey-api/client-fetch

Requires Node.js 18 or later.

Quick start#

typescript
import { validateDocument, type Estate, type Person } from '@openinherit/sdk';

// Validate a document via the INHERIT API
const result = await validateDocument({
  body: estateDocument
});

if (result.data?.valid) {
  console.log('Document is valid');
  console.log('Conformance level:', result.data.conformanceLevel);
} else {
  console.error('Validation errors:', result.data?.errors);
}

How it works#

This SDK is auto-generated from the INHERIT OpenAPI specification using @hey-api/openapi-ts ↗ . It provides:

  • TypeScript types for every INHERIT entity (Estate, Person, Asset, Trust, Bequest, Guardian, Executor, and 100+ more)
  • API client stubs for the INHERIT validation API
  • Multiple schema versions via separate entry points

Entry points#

Import path Contents
@openinherit/sdk Estate v3 types and validation client
@openinherit/sdk/v2 Estate v2 types (legacy)
@openinherit/sdk/reference Reference data API client

API reference#

validateDocument(options)#

Validates an INHERIT document against the v3 JSON Schema via the INHERIT API.

Parameters:

  • options.body — the INHERIT document (estate or catalogue) as a JavaScript object

Returns: Promise<ValidateDocumentResponse> containing:

  • validboolean — whether the document passed validation
  • schemaMode"estate" or "catalogue"
  • conformanceLevel0 (failed), 1 (schema valid), or 2 (schema + referential integrity valid)
  • errors — array of { path, message } objects
  • disclaimer — legal disclaimer string

Type exports#

All INHERIT entity types are exported for use in your application code:

typescript
import type {
  Estate,
  Person,
  Asset,
  Property,
  Trust,
  Bequest,
  Executor,
  Guardian,
  Wish,
  Document,
  Relationship,
  NonprobateTransfer,
  ValidationResult
} from '@openinherit/sdk';

Examples#

Build a typed estate document#

typescript
import type { Estate, Person, Asset } from '@openinherit/sdk';

const testator: Person = {
  id: '550e8400-e29b-41d4-a716-446655440000',
  name: { full: 'Margaret Chen' },
  dateOfBirth: '1952-03-14',
  role: ['testator']
};

const estate: Estate = {
  testatorPersonId: testator.id,
  status: 'draft',
  jurisdictions: ['england-wales']
};

Validate and handle errors#

typescript
import { validateDocument } from '@openinherit/sdk';

async function checkDocument(doc: unknown) {
  const { data, error } = await validateDocument({ body: doc });

  if (error) {
    console.error('API error:', error);
    return;
  }

  if (data.valid) {
    console.log(`Valid (Level ${data.conformanceLevel})`);
  } else {
    for (const err of data.errors) {
      console.log(`  ${err.path}: ${err.message}`);
    }
  }
}

Local validation#

For local validation without an API call, use the @openinherit/schema package with a JSON Schema library like Ajv ↗ :

typescript
import Ajv from 'ajv/dist/2020';
import estateSchema from '@openinherit/schema/v3/schema.json';

const ajv = new Ajv();
const validate = ajv.compile(estateSchema);
const valid = validate(document);

Get in touch

Have a question about INHERIT, or interested in becoming a partner? We'd love to hear from you.

By submitting this form, you agree to our Privacy Policy. Your data is processed by Formspark (EU) and retained until your enquiry is resolved.

or email hello@openinherit.org