JSPM

oip-arweave-types

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

TypeScript types for OIP Arweave templates with optional CLI generator

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (oip-arweave-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    OIP Arweave Types

    TypeScript types for OIP Arweave templates with optional CLI generator

    This package provides automatically updated TypeScript types for OIP Arweave templates. Types are generated during installation, with an optional CLI for advanced usage.

    Features

    • 🎯 Automatic Types - Types generated automatically during installation
    • 🌐 Live API Integration - Fetches latest templates from OIP Arweave API
    • 🔄 Always Up-to-Date - Gets the latest template definitions on install
    • 🎨 Clean Interfaces - Readable TypeScript interfaces with proper typing
    • Zero Configuration - Works out of the box, no setup required
    • 🛠️ Optional CLI - Advanced CLI available for custom workflows

    Installation

    Simply install as a dependency to get automatic types:

    # Install as a project dependency
    npm install oip-arweave-types
    # or
    pnpm add oip-arweave-types

    Types are automatically available in your TypeScript projects:

    // Import the types you need
    import type { Album, Artwork, Person, Basic } from 'oip-arweave-types';
    
    // Use them in your code
    const album: Album = {
        albumTitle: 'My Album',
        artist: 'Artist Name',
    };

    For CLI Usage

    If you want to use the CLI tool for custom workflows:

    # Global installation for CLI usage
    npm install -g oip-arweave-types
    
    # Or use directly with npx
    npx oip-arweave-types generate

    Note: If the automatic generation fails during installation (e.g., no internet connection), you can manually generate types later using the CLI commands below.

    Usage

    Basic Usage

    Generate TypeScript types from all available templates:

    npx oip-arweave-types generate

    This creates oip/generated-types.ts with interfaces for all templates.

    Options

    # Custom output path
    npx oip-arweave-types generate --output ./src/types/oip.ts

    Help

    # General help
    npx oip-arweave-types --help
    
    # Command-specific help
    npx oip-arweave-types generate --help

    Generated Output

    The tool generates clean TypeScript interfaces like:

    export interface Album {
        albumTitle: string;
        artist: string;
        company?: string;
        type?: string;
        year?: number;
    }
    
    export interface Artwork {
        title: string;
        artist: string;
        description?: string;
        medium?: string;
        year?: number;
    }

    The types are always generated using the most recent version of each template, ensuring compatibility with the API.

    API Reference

    The tool connects to the OIP Arweave API at https://api.oip.onl/api/templates to fetch template definitions. Templates are automatically fetched with pre-generated TypeScript types to ensure you get the most accurate type definitions.

    Type Mappings

    OIP field types are mapped to TypeScript as follows:

    • stringstring
    • numbernumber
    • booleanboolean
    • Arrays → T[] (e.g., string[], number[])
    • Nested objects → Nested interfaces

    Optional fields (not marked as required in OIP templates) are generated with the ? optional operator.

    Development

    # Clone the repository
    git clone https://github.com/amingst/oip-arweave-types.git
    cd oip-arweave-types
    
    # Install dependencies
    pnpm install
    
    # Build the project
    pnpm run build
    
    # Test locally
    npx . generate

    Contributing

    1. Fork the repository
    2. Create a feature branch (git checkout -b feature/amazing-feature)
    3. Commit your changes (git commit -m 'Add amazing feature')
    4. Push to the branch (git push origin feature/amazing-feature)
    5. Open a Pull Request

    Changelog

    See CHANGELOG.md for version history and changes.

    License

    MIT © Andrew Mingst


    Built with ❤️ for the Arweave ecosystem