npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@hsuite/client-types

v2.1.0

Published

A comprehensive type system and validation library for Smart Node client operations. This library provides type definitions, interfaces, and runtime validation for client configuration and operations within the Smart Node ecosystem, supporting multiple di

Readme

@hsuite/client-types

A comprehensive type system and validation library for Smart Node client operations. This library provides type definitions, interfaces, and runtime validation for client configuration and operations within the Smart Node ecosystem, supporting multiple distributed ledger networks.

Installation

npm install @hsuite/client-types

Features

  • Type-safe client configuration interfaces - Comprehensive TypeScript interfaces for client setup
  • Multi-ledger support - Configuration for multiple blockchain networks (Hashgraph, Ripple, etc.)
  • Runtime validation - Robust validation for client options with proper error handling
  • Swagger/OpenAPI documentation - Automatic API documentation generation support
  • Comprehensive JSDoc documentation - Detailed inline documentation for all types and interfaces
  • Modular architecture - Separated interfaces and models for clean separation of concerns

Dependencies

Peer Dependencies

  • @nestjs/common: ^10.4.2
  • @nestjs/core: ^10.4.2
  • @hsuite/hashgraph-types: ^2.0.3

Dependencies

  • @hsuite/nestjs-swagger: ^1.0.3

Dev Dependencies

  • @compodoc/compodoc: ^1.1.23

Usage

Basic Configuration

import { IClient, Client } from '@hsuite/client-types';
import { ChainType, LedgerNetwork } from '@hsuite/smart-ledgers';

// Using interfaces for type safety
const options: IClient.IOptions = {
  enabled: true,
  baseUrl: "https://api.smartnode.example.com",
  ledgers: {
    [ChainType.HASHGRAPH]: {
      chain: ChainType.HASHGRAPH,
      network: LedgerNetwork.HEDERA_TESTNET,
      credentials: {
        accountId: "0.0.123456",
        privateKey: "302e020100300506032b657004220420...",
        publicKey: "302a300506032b6570032100..."
      },
      options: {
        maxRetries: 3,
        timeout: 30000
      }
    }
  }
};

// Using models for runtime validation
const clientOptions = new Client.Options(options);

Multi-Ledger Configuration

import { ChainType, LedgerNetwork } from '@hsuite/smart-ledgers';

const multiLedgerOptions: IClient.IOptions = {
  enabled: true,
  baseUrl: "https://api.smartnode.example.com",
  ledgers: {
    [ChainType.HASHGRAPH]: {
      chain: ChainType.HASHGRAPH,
      network: LedgerNetwork.HEDERA_MAINNET,
      credentials: {
        accountId: "0.0.789012",
        privateKey: "302e020100300506032b657004220420...",
        publicKey: "302a300506032b6570032100..."
      }
    },
    [ChainType.RIPPLE]: {
      chain: ChainType.RIPPLE,
      network: LedgerNetwork.XRPL_TESTNET,
      credentials: {
        address: "rUocf1ixKzTuEe34kmVhRvGqNCofY1NJzV",
        seed: "sn3nxiW7v8KXzPzAqzyHXbSSKNuN9"
      }
    }
  }
};

API Documentation

IClient Namespace

The IClient namespace provides interfaces and types for client operations:

IClient.IOptions

Configuration interface for Smart Node client setup:

  • enabled (boolean): Controls whether the client is active and processing requests
  • baseUrl (string): The root URL for all API calls made by the Smart Node client
  • ledgers (Record<ChainType, ILedgerConfig>): Configuration for multiple blockchain networks

Ledger Configuration Properties:

  • chain: The blockchain type (hashgraph, ripple, etc.)
  • network: Network environment (mainnet, testnet, etc.)
  • credentials: Authentication credentials specific to each chain type
  • options: Optional network-specific configuration parameters

Client Namespace

The Client namespace provides concrete implementations with runtime validation:

Client.Options

A class that extends _Options with comprehensive runtime validation:

  • Runtime validation of all configuration parameters
  • Type-safe instantiation with proper error handling
  • Swagger/OpenAPI decorators for automatic API documentation
  • Environment variable validation for ledger configurations

Constructor Validation:

  • Validates ledger configuration completeness
  • Ensures baseUrl is a valid HTTP(S) URL
  • Throws descriptive errors for invalid configurations

Error Handling

The library provides robust error handling:

try {
  const clientOptions = new Client.Options({
    enabled: true,
    baseUrl: "invalid-url", // This will throw an error
    ledgers: {}
  });
} catch (error) {
  console.error('Configuration error:', error.message);
  // Error: Invalid base URL
}

Architecture

src/
├── index.ts                                    # Main entry point
├── interfaces/
│   ├── client.namespace.ts                     # IClient namespace definition
│   └── interfaces/
│       └── client.options.interface.ts         # Client options interface
└── models/
    ├── client.namespace.ts                     # Client namespace definition
    └── models/
        └── client.options.model.ts             # Client options model implementation

Development

Documentation Generation

Generate comprehensive documentation using Compodoc:

npm run compodoc

Check documentation coverage:

npm run compodoc:coverage

Best Practices

  1. Always use interfaces for type definitions - Import from IClient namespace
  2. Use models for runtime validation - Instantiate Client.Options for validation
  3. Handle configuration errors - Wrap instantiation in try-catch blocks
  4. Validate environment variables - Ensure required ledger configurations are present

Version

Current version: 2.0.3

Changelog

See CHANGELOG.md for version history and updates.

License

This package is part of the HSuite Enterprise ecosystem.