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 🙏

© 2025 – Pkg Stats / Ryan Hefner

automate-new-sdk

v1.2.0

Published

Automation framework for Cloudflare Workers

Readme

Automate New SDK

A TypeScript-based automation framework for building and deploying automations to automate.new, powered by Cloudflare Workers and Hono.js.

Overview

This library allows you to create automations with a simple, declarative API. Each automation consists of:

  • Functions: Reusable pieces of logic that can be triggered
  • Triggers: Ways to invoke your functions (manual, webhook, or cron-based)

Your automations are deployed as Cloudflare Workers, making them globally distributed and highly available.

Features

  • Simple, declarative API for defining automations
  • Built on Cloudflare Workers for global deployment
  • Multiple trigger types:
    • Webhook triggers for HTTP-based automation
    • Cron triggers for scheduled tasks (UTC-based)
    • Manual triggers with parameter validation
  • Type-safe function definitions and parameters
  • JSON Schema validation for parameters
  • Built-in logging and error handling
  • Powered by Hono.js for fast HTTP handling

Quick Start

  1. Install the package:
npm install automate-new-cli
  1. Create your automation:
import { task, automate } from 'automate-new-cli';

const myAutomation = task({
  name: "my-automation",
  functions: [
    {
      name: "sayHello",
      parameters: {
        type: "object",
        required: ["name"],
        properties: {
          name: { 
            type: "string",
            description: "Name to greet",
            minLength: 1
          }
        }
      },
      execute: async (params) => {
        console.log(`Hello, ${params.name}!`);
      }
    }
  ],
  triggers: [
    {
      name: "manual-hello",
      type: "manual",
      parameters: {
        type: "object",
        required: ["name"],
        properties: {
          name: { 
            type: "string",
            description: "Name to greet",
            minLength: 1
          }
        }
      },
      execute: async ({ params, trigger }) => {
        await trigger("sayHello", { name: params.name });
      }
    }
  ]
});

export default {
  fetch: automate.serve(myAutomation).fetch
};
  1. Deploy to Cloudflare Workers:
npm run deploy

API Reference

Task Definition

A task is the main building block of an automation. It consists of functions and triggers:

interface AutomationTask {
  name: string;
  triggers: Trigger[];
  functions: AutomationFunction[];
}

Parameter Validation

The SDK uses JSON Schema for parameter validation. This provides rich validation capabilities:

{
  parameters: {
    type: "object",
    required: ["email", "subject"],
    properties: {
      email: {
        type: "string",
        format: "email",
        description: "Recipient email address"
      },
      subject: {
        type: "string",
        minLength: 1,
        maxLength: 100,
        description: "Email subject line"
      },
      body: {
        type: "string",
        default: "Default message",
        examples: ["Example message 1", "Example message 2"]
      }
    }
  }
}

Supported validations include:

  • Type checking (type)
  • Required fields (required)
  • String formats (format)
  • Length constraints (minLength, maxLength)
  • Numeric ranges (minimum, maximum)
  • Pattern matching (pattern)
  • Enums (enum)
  • Default values (default)
  • And more...

Trigger Types

Manual Trigger

Allows manual invocation with parameter validation:

{
  name: "my-trigger",
  type: "manual",
  parameters: {
    type: "object",
    properties: {
      // JSON Schema validation
    }
  },
  execute: async ({ params, trigger }) => {
    // Your trigger logic
  }
}

Webhook Trigger

Handles HTTP requests:

{
  name: "webhook-trigger",
  type: "webhook",
  execute: async ({ req, res, trigger }) => {
    // Your webhook logic
  }
}

Cron Trigger

Runs on a schedule (UTC time):

{
  name: "scheduled-trigger",
  type: "cron",
  cron: "0 19 * * *", // Runs at 19:00 UTC (2:00 PM EST)
  execute: async ({ trigger }) => {
    // Your scheduled logic
  }
}

HTTP Endpoints

When deployed, your automation exposes these endpoints:

  • POST /{function-name} - Direct function execution
  • POST /manual-trigger/{trigger-name} - Manual trigger execution
  • POST /webhook/{trigger-name} - Webhook trigger endpoint
  • POST /cronjob-trigger/{trigger-name} - Cron trigger endpoint
  • GET / - Health check endpoint

Development

  1. Clone the repository:
git clone https://github.com/yourusername/automate-new-cli.git
  1. Install dependencies:
npm install
  1. Run locally:
npm run dev

License

Apache License 2.0. See LICENSE for more details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.