A CLI tool for managing high-quality Flow type definitions for third-party JavaScript libraries
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
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.
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"
});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);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'
});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');
});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>;
}flowVersionStr is provided, only returns definitions compatible with that Flow versionSearch results are displayed in a table format with columns:
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 │
└─────────────┴─────────────────┴──────────────┘