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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lyku/lockstep-client-ts

v1.5.0

Published

Generate fully-typed TypeScript HTTP clients from TsonSchema-based API definitions

Readme

@lyku/lockstep-client-ts

Generate fully-typed TypeScript HTTP clients from TsonSchema-based API definitions.

Overview

This package takes a set of external API model definitions (request/response schemas, HTTP methods, path patterns) and produces a complete, self-contained TypeScript HTTP client file. It is used within the Lyku monorepo to generate typed clients for third-party APIs such as Valhalla (routing), Pelias (geocoding), TomTom (maps), and OTP (transit).

Installation

npm install @lyku/lockstep-client-ts

Requires @lyku/lockstep-core as a peer dependency for schema-to-type conversion.

API

generateTsClient(options: GenerateTsClientOptions): Promise<void>

Generates a TypeScript client file in the specified output directory.

import { generateTsClient } from '@lyku/lockstep-client-ts';
import { valhallaModels } from '@myapp/api-models';

await generateTsClient({
	models: valhallaModels,
	name: 'Valhalla',
	outputDir: './dist/libs/valhalla-client',
});

Options

| Option | Type | Required | Description | | ---------------- | ------------------------ | -------- | --------------------------------------------------------------- | | models | ExternalApiSpec | Yes | Record of endpoint names to ExternalApiModel definitions | | name | string | Yes | Client name (e.g., 'Valhalla'), used for generated type names | | outputDir | string | Yes | Directory to write index.ts into | | paramMapping | Record<string, string> | No | Map camelCase params to API-specific formats (e.g., dotted) | | apiKeyParam | string | No | Query parameter name for API key injection | | customMethods | Record<string, string> | No | Custom method implementations for complex endpoints | | defaultHeaders | Record<string, string> | No | Headers included in every request | | format | boolean | No | Format with Prettier (default: true) | | errorClassName | string | No | Custom error class name (default: ${Name}Error) | | cjs | boolean | No | Generate CommonJS output (default: false) |

validateApiSpec(spec: ExternalApiSpec): string[]

Validates an API specification and returns an array of error messages (empty if valid).

import { validateApiSpec } from '@lyku/lockstep-client-ts';

const errors = validateApiSpec(myModels);
if (errors.length > 0) {
	console.error('Invalid spec:', errors);
}

Key Types

type ExternalApiModel = {
	method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
	path: string;
	request?: TsonSchema;
	queryParams?: TsonSchema;
	pathParams?: readonly string[];
	response?: TsonSchema;
	authenticated?: boolean;
	description?: string;
};

type ExternalApiSpec = Record<string, ExternalApiModel>;

Generated Output

For a client named Valhalla, the generated index.ts contains:

  • Request/Response types for every endpoint (e.g., RouteRequest, RouteResponse)
  • Type map (ValhallaTypes) mapping endpoint names to their request/response pairs
  • Error class (ValhallaError) extending Error with status code and body
  • Client factory (createValhallaClient()) returning an object with typed methods for each endpoint
  • Client type (ValhallaClient) inferred from the factory return type

The generated client uses fetch with AbortController for timeout support and handles JSON serialization/deserialization automatically.

Where it fits

Dependencies

  • @lyku/lockstep-core (peer) -- schema-to-TypeScript-type conversion via tsonToType
  • prettier -- optional output formatting

License

GPL-3.0