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

@keyflow/sdk

v0.4.1

Published

This documentation provides detailed requirements and guides for the Keyflow SDK components. The SDK enables developers to define, version, and serve custom blocks that process input data and integrate with external services.

Readme

Keyflow SDK Documentation

This documentation provides detailed requirements and guides for the Keyflow SDK components. The SDK enables developers to define, version, and serve custom blocks that process input data and integrate with external services.

Components

The Keyflow SDK consists of several key components, each with its own detailed documentation:

  1. Fields API - Define input fields for blocks using a fluent, chainable API
  2. Block API - Create and configure processing blocks with input/output schemas
  3. Block Versioning API - Manage multiple versions of blocks
  4. Server API - Initialize and configure the HTTP server
  5. Oauth Credential Access - Securely access third-party credentials

Quick Start

To get started with the Keyflow SDK, follow these steps:

  1. Install the SDK package:

    npm install @keyflow/sdk
  2. Create a block file (e.g., blocks/reverse-text.ts):

    import { block, fields } from '@keyflow/sdk';
    
    const reverseText = block('reverse-text')
      .version('v1')
      .title('Reverse Text')
      .description('Reverses a given input string')
      .input({
        text: fields.text().label('Text to reverse').required(),
      })
      .output({
        reversedText: 'string',
      })
      .execute(async ({ input }) => {
        const reversedText = input.text.split('').reverse().join('');
        return { reversedText };
      });
    
    export const blocks = [reverseText];
  3. Create a server file (e.g., src/main.ts):

    import { server } from '@keyflow/sdk';
    import { blocks } from '../blocks/reverse-text';
    
    // Start the server
    server({ apiKey: process.env.KEYFLOW_API_KEY })
      .register(...blocks);
  4. Create a .env file with your Keyflow API key:

    KEYFLOW_API_KEY=your_keyflow_api_key_here
    NODE_ENV=development
  5. Start the server:

    ts-node src/main.ts

Recommended Project Structure

my-keyflow-project/
├── blocks/
│   ├── reverse-text.ts        # v1 and v2 versions
│   ├── uppercase-text.ts      # v1 version
│   └── another-block.ts       # Additional blocks
├── src/
│   └── main.ts                # Server setup and registration
├── .env                       # KEYFLOW_API_KEY, NODE_ENV
├── .gitignore                 # Ignore node_modules, .env, dist
├── package.json               # Dependencies (@keyflow/sdk, dotenv)
├── tsconfig.json              # TypeScript configuration
└── README.md                  # Documentation

Key Concepts

Fluent API

The Keyflow SDK uses a fluent, chainable API style for intuitive development:

block('my-block')
  .title('My Block')
  .description('Does something useful')
  .input({ /* ... */ })
  .output({ /* ... */ })
  .execute(async ({ input, ctx }) => { /* ... */ });

Type Safety

The SDK provides end-to-end type safety with TypeScript:

  • Input validation based on field definitions
  • Output validation based on output schema
  • Type-safe credential access

HTTP Endpoints

Each block is automatically mapped to an HTTP endpoint:

  • Format: POST /<block-identifier>/<version>
  • Example: POST /reverse-text/v1

Credential Security

Credentials are securely accessed at runtime:

.execute(async ({ input, ctx }) => {
  const token = await ctx.credentials('service_name');
  // Use token securely
});

File Handling

The SDK provides powerful file handling capabilities through the FileObject class:

// Define a block that processes uploaded files
const processFile = block('process-file')
  .input({
    document: fields.file().label('Upload Document'),
    csvData: fields.file().label('CSV Data').optional(),
  })
  .execute(async ({ input }) => {
    // Download files
    const documentBuffer = await input.document.download();
    await input.document.download('saved-document.pdf', './uploads');
    
    // Read file content (automatically parsed by extension)
    const content = await input.document.read(); // string | object | string[]
    
    if (input.csvData) {
      // Read CSV with headers (default)
      const rows = await input.csvData.read(); // Record<string, string>[]
      
      // Read CSV without headers
      const rawData = await input.csvData.read({ headers: false }); // string[][]
      
      // Read CSV with custom delimiter
      const semiColonData = await input.csvData.read({ delimiter: ';' });
    }
    
    return { processed: true };
  });

Supported file types for reading:

  • Text files (.txt, .md): Return as string
  • JSON files (.json): Return as parsed object
  • CSV files (.csv): Return as Record<string, string>[] or string[][]
  • XML/HTML files (.xml, .html): Return as string
  • Log files (.log): Return as string[] (one entry per line)
  • Other files: Return as string

Further Reading

For more detailed information about each component, please refer to the specific documentation sections linked above.