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

@restflow/engine

v1.3.1

Published

The core execution engine for Restflow CLI that orchestrates the complete pipeline for executing .flow files.

Downloads

18

Readme

@restflow/engine

The core execution engine for Restflow CLI that orchestrates the complete pipeline for executing .flow files.

Features

  • Complete Pipeline Orchestration: Integrates all Restflow packages (parser, variables, environment, HTTP, assertions, reporter)
  • Step-by-Step Execution: Executes flow steps sequentially with proper context management
  • Variable Resolution: Resolves {{variables}} in requests using environment and captured variables
  • HTTP Request Execution: Makes HTTP requests with proper error handling and timing
  • Assertion Evaluation: Evaluates assertions on responses
  • Capture Directives: Captures values from responses for use in subsequent steps
  • Error Handling: Comprehensive error handling with detailed error information
  • Timing Metrics: Tracks execution duration for flows and individual steps

Installation

npm install @restflow/engine

Usage

Basic Flow Execution

import { FlowExecutor, executeFlowFromString } from '@restflow/engine';

// Simple execution from string
const flowContent = `
### Login
POST https://api.example.com/login
Content-Type: application/json

{
  "username": "{{username}}",
  "password": "{{password}}"
}

> capture token = body.access_token
> assert status == 200

### Get Profile
GET https://api.example.com/profile
Authorization: Bearer {{token}}

> assert status == 200
> assert body.id exists
`;

const result = await executeFlowFromString(flowContent, {
  config: {
    variables: {
      username: '[email protected]',
      password: 'secret123'
    }
  }
});

console.log(`Flow ${result.success ? 'succeeded' : 'failed'}`);
console.log(`Duration: ${result.duration}ms`);

Advanced Usage with Environment

import { FlowExecutor } from '@restflow/engine';

const executor = new FlowExecutor({
  config: {
    timeout: 10000,
    retries: 3,
    baseUrl: 'https://api.example.com'
  }
});

// Execute with environment file
const result = await executor.executeFlow(flowContent, '.env');

// Process results
for (const step of result.steps) {
  console.log(`Step: ${step.step.name}`);
  console.log(`Duration: ${step.duration}ms`);
  
  if (step.error) {
    console.error(`Error: ${step.error.message}`);
  }
  
  if (step.response) {
    console.log(`Status: ${step.response.status}`);
    console.log(`Response Time: ${step.response.responseTime}ms`);
  }
  
  // Check directive results
  for (const directive of step.directives) {
    if (directive.directive.type === 'assert') {
      console.log(`Assertion: ${directive.success ? 'PASS' : 'FAIL'}`);
    } else if (directive.directive.type === 'capture') {
      console.log(`Captured: ${directive.capturedValue}`);
    }
  }
}

Custom Configuration

import { FlowExecutor } from '@restflow/engine';
import { HttpClient } from '@restflow/http';
import { DefaultVariableResolver } from '@restflow/variables';
import { EnvironmentManager } from '@restflow/environment';

const customHttpClient = new HttpClient({
  timeout: 30000,
  retries: 2,
  followRedirects: true
});

const customVariableResolver = new DefaultVariableResolver();
const customEnvironmentManager = new EnvironmentManager();

const executor = new FlowExecutor({
  httpClient: customHttpClient,
  variableResolver: customVariableResolver,
  environmentManager: customEnvironmentManager,
  config: {
    timeout: 30000,
    variables: {
      baseUrl: 'https://staging.api.example.com'
    }
  }
});

API Reference

FlowExecutor

Main class for executing flows.

Constructor

new FlowExecutor(options?: FlowExecutorOptions)

Options:

  • config?: RestflowConfig - Configuration for timeouts, retries, variables, etc.
  • environmentPath?: string - Path to environment file
  • variableResolver?: DefaultVariableResolver - Custom variable resolver
  • httpClient?: HttpClient - Custom HTTP client
  • assertionEvaluator?: DefaultAssertionEvaluator - Custom assertion evaluator
  • environmentManager?: EnvironmentManager - Custom environment manager

Methods

executeFlow(flowContent: string, environmentPath?: string): Promise<FlowResult>

Parse and execute a flow from string content.

executeFlowObject(flow: Flow, environmentPath?: string): Promise<FlowResult>

Execute a pre-parsed Flow object.

Convenience Functions

executeFlowFromString(flowContent: string, options?: FlowExecutorOptions): Promise<FlowResult>

Quick execution of a flow from string content.

executeFlowWithEnvironment(flowContent: string, environmentPath: string, options?: FlowExecutorOptions): Promise<FlowResult>

Execute a flow with an environment file.

Building

Run nx build @restflow/engine to build the library.

Testing

Run nx test @restflow/engine to run the tests.