JSPM

@schemacompany/core

0.1.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q26078F
  • License MIT

Core utilities for The Schema Company SDKs

Package Exports

  • @schemacompany/core

Readme

@schemacompany/core

Core utilities for The Schema Company SDKs. This package provides the base client, types, and error handling used by all other SDK packages.

Installation

npm install @schemacompany/core

Usage

import { SchemaClient } from "@schemacompany/core";

const client = new SchemaClient();

// Fetch a schema by hash
const schema = await client.fetchSchema("a1b2c3d4...");
console.log(schema);
// { "@context": "https://schema.org", "@type": "WebPage", ... }

// Fetch as raw JSON string
const raw = await client.fetchSchemaRaw("a1b2c3d4...");
console.log(raw);
// '{"@context":"https://schema.org",...}'

// Validate a hash format
const isValid = client.validateHash("a1b2c3d4...");

API

SchemaClient

class SchemaClient {
  constructor(config?: SchemaCompanyConfig);
  fetchSchema(hash: string): Promise<Schema>;
  fetchSchemaRaw(hash: string): Promise<string>;
  validateHash(hash: string): boolean;
}

SchemaCompanyConfig

interface SchemaCompanyConfig {
  baseUrl?: string;  // Default: https://assets.theschemacompany.com
  timeout?: number;  // Default: 5000ms
}

Error Classes

  • SchemaCompanyError - Base error class
  • SchemaNotFoundError - Thrown when schema hash is not found (404)
  • SchemaFetchError - Thrown on network or parse errors
  • InvalidHashError - Thrown when hash format is invalid

Constants

import { DEFAULT_BASE_URL, HASH_REGEX } from "@schemacompany/core";

// DEFAULT_BASE_URL: "https://assets.theschemacompany.com"
// HASH_REGEX: /^[a-f0-9]{64}$/i

License

MIT