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

@etaio/core-types

v2.0.0

Published

Core TypeScript type definitions for the Etaio generative AI ecosystem

Readme

@etaio/core-types

Core TypeScript type definitions and interfaces for the Etaio generative AI ecosystem.

Installation

npm install @etaio/core-types
# or
pnpm add @etaio/core-types

Overview

This package provides the foundational types and interfaces used across all Etaio packages, ensuring type safety and consistency throughout the ecosystem.

Core Types

GenerativeAsset

Base interface for all generated assets (images, videos, audio):

import { GenerativeAsset } from '@etaio/core-types';

const asset: GenerativeAsset = {
  id: 'asset-123',
  type: 'image',
  url: 'https://example.com/image.jpg',
  metadata: {
    provider: 'openai',
    model: 'dall-e-3',
    generatedAt: '2024-01-01T00:00:00Z'
  }
};

GenerationCost

Track and estimate generation costs:

import { GenerationCost } from '@etaio/core-types';

const cost: GenerationCost = {
  provider: 'stability',
  model: 'sdxl',
  estimatedCost: 0.05,
  actualCost: 0.048,
  currency: 'USD',
  confidence: 'high',
  breakdown: {
    credits: { count: 1, costPerCredit: 0.048 }
  }
};

UsageRecord

Track usage across providers:

import { UsageRecord } from '@etaio/core-types';

const usage: UsageRecord = {
  id: 'usage-123',
  userId: 'user-456',
  projectId: 'project-789',
  provider: 'openai',
  model: 'dall-e-3',
  type: 'image',
  cost: 0.04,
  currency: 'USD',
  timestamp: '2024-01-01T00:00:00Z'
};

GenerativeProvider

Base interface for implementing providers:

import { GenerativeProvider } from '@etaio/core-types';

class MyProvider implements GenerativeProvider {
  type = 'image' as const;
  name = 'my-provider';
  models = ['model-1', 'model-2'];
  
  async isAvailable(): Promise<boolean> {
    // Check if provider is available
    return true;
  }
  
  async generate(request: any): Promise<any> {
    // Generate content
  }
  
  async estimateCost(request: any): Promise<GenerationCost> {
    // Estimate generation cost
  }
  
  validateRequest(request: any): ValidationResult {
    // Validate request
  }
  
  getLimits(): ProviderLimits {
    // Return provider limits
  }
  
  getCapabilities(): ProviderCapabilities {
    // Return provider capabilities
  }
}

Provider Capabilities & Limits

import { ProviderCapabilities, ProviderLimits } from '@etaio/core-types';

const capabilities: ProviderCapabilities = {
  streaming: true,
  batching: true,
  variations: true,
  editing: false,
  customModels: false
};

const limits: ProviderLimits = {
  maxPromptLength: 4000,
  maxBatchSize: 10,
  maxDimensions: { width: 2048, height: 2048 },
  minDimensions: { width: 256, height: 256 },
  supportedFormats: ['png', 'jpeg', 'webp'],
  rateLimit: {
    requests: 100,
    window: 60 // seconds
  }
};

Budget Management

import { GenerationBudget } from '@etaio/core-types';

const budget: GenerationBudget = {
  daily: 10.00,
  monthly: 200.00,
  perRequest: 1.00,
  currency: 'USD'
};

Error Handling

import { ProviderError } from '@etaio/core-types';

throw new ProviderError(
  'Provider unavailable',
  'PROVIDER_UNAVAILABLE',
  'openai',
  true // retryable
);

Asset Types

ImageAsset

import { ImageAsset } from '@etaio/core-types';

const image: ImageAsset = {
  id: 'img-123',
  type: 'image',
  url: 'https://example.com/image.jpg',
  thumbnailUrl: 'https://example.com/thumb.jpg',
  dimensions: { width: 1024, height: 1024 },
  format: 'jpeg',
  size: 2048000, // bytes
  metadata: {
    provider: 'openai',
    model: 'dall-e-3',
    prompt: 'A beautiful sunset'
  }
};

VideoAsset

import { VideoAsset } from '@etaio/core-types';

const video: VideoAsset = {
  id: 'vid-123',
  type: 'video',
  url: 'https://example.com/video.mp4',
  duration: 5.0, // seconds
  fps: 24,
  resolution: { width: 1920, height: 1080 },
  format: 'mp4',
  codec: 'h264'
};

AudioAsset

import { AudioAsset } from '@etaio/core-types';

const audio: AudioAsset = {
  id: 'aud-123',
  type: 'audio',
  url: 'https://example.com/audio.mp3',
  duration: 30.5, // seconds
  format: 'mp3',
  sampleRate: 44100,
  bitrate: 128000,
  channels: 2
};

Usage Statistics

import { UsageStats } from '@etaio/core-types';

const stats: UsageStats = {
  totalCost: 42.50,
  totalCount: 150,
  byProvider: {
    openai: { cost: 30.00, count: 100 },
    stability: { cost: 12.50, count: 50 }
  },
  byType: {
    image: { cost: 25.00, count: 80 },
    video: { cost: 15.00, count: 50 },
    audio: { cost: 2.50, count: 20 }
  },
  daily: [
    { date: '2024-01-01', cost: 10.00, count: 30 }
  ],
  monthly: [
    { month: '2024-01', cost: 42.50, count: 150 }
  ]
};

TypeScript Benefits

  • ✅ Full type safety across all Etaio packages
  • ✅ IntelliSense support in modern IDEs
  • ✅ Compile-time error checking
  • ✅ Self-documenting code
  • ✅ Consistent API interfaces

License

MIT © Etaio

Support

For issues and feature requests, please visit our GitHub repository.