CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-flow-typed

A CLI tool for managing high-quality Flow type definitions for third-party JavaScript libraries

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

search.mddocs/

Search and Discovery

Search functionality for finding available type definitions in the flow-typed repository. This system provides both command-line and programmatic access to the catalog of available library definitions.

Capabilities

Library Definition Search

Search for available library definitions by name with optional Flow version filtering.

/**
 * Perform a simple search (by name) of available libdefs
 * @param args - Search configuration options
 * @returns Promise resolving to exit code (0 for success)
 */
function search(args: SearchArgs): Promise<number>;

interface SearchArgs {
  /** Search term to look for in library names */
  term: string;
  /** Flow version that fetched libdefs must be compatible with */
  flowVersion?: string;
}

Usage Examples:

import { search } from "flow-typed";

// Basic search
const result = await search({
  term: "react"
});

// Search with Flow version constraint
const result = await search({
  term: "lodash",
  flowVersion: "v0.83.0"
});

// Search for scoped packages
const result = await search({
  term: "@types/node"
});

Search Results Formatting

Utility function for formatting search results into a readable table format.

/**
 * Format library definitions into a table for display
 * @param defs - Array of library definitions to format
 * @returns Formatted string containing table or "no results" message
 */
function _formatDefTable(defs: Array<LibDef>): string;

Usage Example:

import { _formatDefTable, getCacheLibDefs, filterLibDefs } from "flow-typed";

// Get and format search results
const defs = await getCacheLibDefs();
const filtered = filterLibDefs(defs, {
  type: 'fuzzy',
  term: 'express',
  flowVersionStr: 'v0.83.0'
});
const table = _formatDefTable(filtered);
console.log(table);

Library Definition Filtering

Advanced filtering capabilities for library definitions with multiple filter types.

/**
 * Filter library definitions based on search criteria
 * @param defs - Array of library definitions to filter
 * @param filter - Filter configuration object
 * @returns Filtered array of library definitions
 */
function filterLibDefs(
  defs: Array<LibDef>,
  filter: FilterOptions
): Array<LibDef>;

interface FilterOptions {
  /** Type of filtering to perform */
  type: 'fuzzy' | 'exact';
  /** Search term to match against */
  term: string;
  /** Optional Flow version string for compatibility filtering */
  flowVersionStr?: string;
}

Usage Examples:

import { filterLibDefs, getCacheLibDefs } from "flow-typed";

const allDefs = await getCacheLibDefs();

// Fuzzy search (partial matches)
const fuzzyResults = filterLibDefs(allDefs, {
  type: 'fuzzy',
  term: 'react',
  flowVersionStr: 'v0.83.0'
});

// Exact search (exact name matches)
const exactResults = filterLibDefs(allDefs, {
  type: 'exact',
  term: 'react-dom'
});

Cache Library Definitions Access

Direct access to cached library definitions for custom search implementations.

/**
 * Get cached library definitions from the local repository
 * @param verbose - Optional verbose output stream for logging
 * @returns Promise resolving to array of all cached library definitions
 */
function getCacheLibDefs(verbose?: any): Promise<Array<LibDef>>;

Usage Example:

import { getCacheLibDefs } from "flow-typed";

// Get all cached definitions
const allDefs = await getCacheLibDefs();

// Custom filtering logic
const customFiltered = allDefs.filter(def => {
  return def.pkgName.includes('test') && 
         def.flowVersionStr.startsWith('v0.8');
});

Library Definition Structure

The structure of library definition objects returned by search operations.

interface LibDef {
  /** Package name (e.g., "lodash", "@types/react") */
  pkgName: string;
  /** Package version string (e.g., "4.x.x", "^16.0.0") */
  pkgVersionStr: string;
  /** Path to configuration file or null */
  configPath: string | null;
  /** Flow version compatibility object */
  flowVersion: FlowVersion;
  /** Flow version as string (e.g., "v0.83.x") */
  flowVersionStr: string;
  /** File system path to the definition */
  path: string;
  /** Array of paths to test files for this definition */
  testFilePaths: Array<string>;
}

Search Behavior

Fuzzy Search

  • Matches partial package names
  • Case-insensitive matching
  • Supports substring matching anywhere in the package name

Exact Search

  • Requires exact package name match
  • Case-sensitive matching
  • Useful for finding specific packages

Flow Version Filtering

  • When flowVersionStr is provided, only returns definitions compatible with that Flow version
  • Version compatibility follows semantic versioning rules
  • Supports version ranges and specific versions

Output Format

Search results are displayed in a table format with columns:

  • Name: Package name
  • Package Version: Version range supported by the definition
  • Flow Version: Flow version compatibility

Example output:

Found definitions:
┌─────────────┬─────────────────┬──────────────┐
│ Name        │ Package Version │ Flow Version │
├─────────────┼─────────────────┼──────────────┤
│ react       │ ^16.0.0         │ >=v0.83.x    │
│ react-dom   │ ^16.0.0         │ >=v0.83.x    │
│ react-redux │ ^7.0.0          │ >=v0.83.x    │
└─────────────┴─────────────────┴──────────────┘

Error Handling

  • Search operations return exit codes (0 for success)
  • Network errors during cache access are handled gracefully
  • Invalid search terms or Flow versions result in appropriate error messages
  • Empty search results display "No definitions found, sorry!" message

docs

cli-commands.md

creation.md

flow-versions.md

index.md

installation.md

libdefs.md

search.md

tile.json