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

@teliagen/client

v0.4.2

Published

Universal Core Client for Teliagen Framework

Readme

@teliagen/client

Universal HTTP client for Teliagen applications.

npm version TypeScript License: Apache-2.0

Overview

@teliagen/client provides a lightweight HTTP transport for calling Teliagen actions:

  • Universal – Works in Node.js and browsers
  • Type-Safe – Full TypeScript support
  • Simple API – Call actions by name with typed inputs
  • Configurable – Custom headers, auth, interceptors

Installation

npm install @teliagen/client
# or
pnpm add @teliagen/client

Quick Start

import { TeliagenTransport } from '@teliagen/client';

const client = new TeliagenTransport({
  baseUrl: 'http://localhost:3000/api'
});

// Call an action
const user = await client.execute<LoginInput, LoginOutput>(
  'login',
  { email: '[email protected]', password: 'secret' }
);

console.log(user.token);

Configuration

interface TeliagenClientConfig {
  // Required
  baseUrl: string;              // API base URL
  
  // Optional
  headers?: Record<string, string>;  // Default headers
  timeout?: number;             // Request timeout (ms)
  
  // Authentication
  token?: string;               // Bearer token
  apiKey?: string;              // API key header
  
  // Callbacks
  onError?: (error: any) => void;
  onRequest?: (config: any) => any;
  onResponse?: (response: any) => any;
}

Examples

Basic Usage

import { TeliagenTransport } from '@teliagen/client';

const client = new TeliagenTransport({
  baseUrl: 'http://localhost:3000/api'
});

// Simple action call
const users = await client.execute('listUsers', {});

// With types
interface CreateUserInput {
  email: string;
  name: string;
}

interface User {
  id: string;
  email: string;
  name: string;
}

const newUser = await client.execute<CreateUserInput, User>(
  'createUser',
  { email: '[email protected]', name: 'Alice' }
);

With Authentication

const client = new TeliagenTransport({
  baseUrl: 'http://localhost:3000/api',
  token: localStorage.getItem('authToken')
});

// Token is sent as: Authorization: Bearer <token>

// Or use API key
const client = new TeliagenTransport({
  baseUrl: 'http://localhost:3000/api',
  apiKey: 'your-api-key'
});

// API key is sent as: x-teliagen-key: <apiKey>

Module and Provider Routing

// Call action in specific module/provider
const result = await client.execute(
  'getOrderDetails',
  { orderId: '123' },
  {
    module: 'orders',
    provider: 'OrderActions'
  }
);

// Calls: POST /api/actions/getOrderDetails
// Headers: x-teliagen-module: orders
//          x-teliagen-provider: OrderActions

Cross-Service Calls

// Call action on a federated service
const result = await client.execute(
  'processPayment',
  { amount: 99.99 },
  {
    server: 'payments'
  }
);

// Calls: POST /api/actions/processPayment
// Headers: x-teliagen-server: payments

Dynamic Token

const client = new TeliagenTransport({
  baseUrl: 'http://localhost:3000/api',
  onRequest: (config) => {
    // Add fresh token on each request
    const token = localStorage.getItem('authToken');
    if (token) {
      config.headers['Authorization'] = `Bearer ${token}`;
    }
    return config;
  }
});

Error Handling

const client = new TeliagenTransport({
  baseUrl: 'http://localhost:3000/api',
  onError: (error) => {
    if (error.response?.status === 401) {
      // Redirect to login
      window.location.href = '/login';
    }
  }
});

try {
  const result = await client.execute('protectedAction', {});
} catch (error) {
  console.error('Action failed:', error.message);
}

TeliagenTransport API

class TeliagenTransport {
  constructor(config: TeliagenClientConfig);
  
  // Execute an action
  execute<TInput, TOutput>(
    action: string,
    input: TInput,
    options?: {
      module?: string;
      provider?: string;
      server?: string;
      prefix?: string;
      headers?: Record<string, string>;
    }
  ): Promise<TOutput>;
  
  // Update configuration
  setToken(token: string): void;
  setHeader(key: string, value: string): void;
  removeHeader(key: string): void;
}

Response Types

interface TeliagenResponse<T> {
  data: T;
  status: number;
  headers: Record<string, string>;
}

// The execute method returns the data directly
// For full response, use executeRaw:
const response = await client.executeRaw<Input, Output>('action', input);
console.log(response.status);  // 200
console.log(response.data);    // { ... }

Browser Usage

<script src="https://cdn.example.com/@teliagen/client/dist/client.umd.js"></script>
<script>
  const client = new TeliagenClient.TeliagenTransport({
    baseUrl: 'http://localhost:3000/api'
  });
  
  client.execute('listProducts', {})
    .then(products => console.log(products));
</script>

Integration with Frameworks

React

Use @teliagen/react for React integration with hooks.

Vue

// composables/useTeliagen.ts
import { ref } from 'vue';
import { TeliagenTransport } from '@teliagen/client';

const client = new TeliagenTransport({
  baseUrl: import.meta.env.VITE_API_URL
});

export function useAction<TInput, TOutput>(action: string) {
  const data = ref<TOutput>();
  const loading = ref(false);
  const error = ref<Error>();

  const execute = async (input: TInput) => {
    loading.value = true;
    try {
      data.value = await client.execute<TInput, TOutput>(action, input);
    } catch (e) {
      error.value = e as Error;
    } finally {
      loading.value = false;
    }
  };

  return { data, loading, error, execute };
}

Svelte

// stores/teliagen.ts
import { writable } from 'svelte/store';
import { TeliagenTransport } from '@teliagen/client';

export const client = new TeliagenTransport({
  baseUrl: import.meta.env.VITE_API_URL
});

export function createActionStore<TInput, TOutput>(action: string) {
  const { subscribe, set } = writable<TOutput | null>(null);
  
  return {
    subscribe,
    execute: async (input: TInput) => {
      const result = await client.execute<TInput, TOutput>(action, input);
      set(result);
      return result;
    }
  };
}

Requirements

  • Node.js >= 18.0.0 (for Node.js usage)
  • Modern browser (for browser usage)

Related Packages

Documentation

For full documentation, visit docs.teliagen.org.

License

Apache-2.0