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

trigger-mesh-sdk

v1.0.13

Published

Official TriggerMesh SDK for Node.js

Downloads

76

Readme

TriggerMesh SDK

Official TypeScript/JavaScript SDK for the TriggerMesh automation platform.

Installation

Option 1: NPM (Recommended)

npm install @trigger-mesh/sdk

Option 2: Local Development

npm install ../trigger-mesh-sdk

Option 3: Git Installation

npm install git+https://github.com/yourusername/trigger-mesh-sdk.git

Quick Start

import { TriggerMeshSDK } from '@trigger-mesh/sdk';

// Initialize SDK
const sdk = new TriggerMeshSDK({
  apiKey: 'your-api-key-here',
  baseUrl: 'http://localhost:3000', // Your backend URL
  timeout: 30000
});

// Create a workflow
const workflow = await sdk.workflows.create({
  name: 'Daily Report Generator',
  description: 'Generates daily reports automatically',
  desktopId: 'desktop-123',
  parameters: {
    reportType: 'daily',
    format: 'pdf'
  }
});

// Schedule it to run daily at 9 AM
const cronJob = await sdk.cronJobs.create({
  name: 'Daily Report - 9 AM',
  workflowId: workflow.id,
  desktopId: 'desktop-123',
  cronExpression: '0 9 * * *',
  timezone: 'UTC'
});

// Run immediately
const task = await sdk.tasks.create({
  workflowId: workflow.id,
  desktopId: 'desktop-123',
  triggerType: 'MANUAL'
});

API Reference

Core Managers

WorkflowManager

// Create workflow
const workflow = await sdk.workflows.create(data);

// Get workflow by ID
const workflow = await sdk.workflows.getById(id);

// List workflows
const workflows = await sdk.workflows.getAll(filters);

// Update workflow
const updated = await sdk.workflows.update(id, data);

// Delete workflow
await sdk.workflows.delete(id);

// Execute workflow
const result = await sdk.workflows.execute(workflowId, parameters);

TaskManager

// Create task
const task = await sdk.tasks.create({
  workflowId: 'workflow-123',
  desktopId: 'desktop-123',
  priority: 1,
  parameters: { key: 'value' },
  triggerType: 'MANUAL'
});

// Get task by ID
const task = await sdk.tasks.getById(id);

// List tasks
const tasks = await sdk.tasks.getAll(filters);

// Cancel task
await sdk.tasks.cancel(id);

// Retry failed task
await sdk.tasks.retry(id);

CronJobManager

// Create cron job
const cronJob = await sdk.cronJobs.create({
  name: 'Daily Backup',
  workflowId: 'workflow-123',
  desktopId: 'desktop-123',
  cronExpression: '0 2 * * *',
  timezone: 'UTC'
});

// List cron jobs
const cronJobs = await sdk.cronJobs.getAll();

// Activate/Deactivate
await sdk.cronJobs.activate(id);
await sdk.cronJobs.deactivate(id);

// Trigger manually
await sdk.cronJobs.trigger(id, parameters);

WebhookManager

// Incoming webhooks (trigger workflows)
const incoming = await sdk.webhooks.createIncoming({
  name: 'API Trigger',
  workflowId: 'workflow-123',
  desktopId: 'desktop-123',
  url: 'https://your-app.com/webhook',
  secret: 'your-secret'
});

// Outgoing webhooks (task notifications)
const outgoing = await sdk.webhooks.createOutgoing({
  taskId: 'task-123',
  url: 'https://your-app.com/notifications',
  events: ['task.completed', 'task.failed']
});

Convenience Methods

// Create and schedule workflow in one call
const { workflow, cronJob } = await sdk.createAndScheduleWorkflow({
  name: 'Weekly Backup',
  desktopId: 'desktop-123',
  cronExpression: '0 2 * * 0',
  parameters: { backupType: 'full' }
});

// Create and run workflow immediately
const { workflow, task } = await sdk.createAndRunWorkflow({
  name: 'Immediate Test',
  desktopId: 'desktop-123',
  priority: 1
});

// Get comprehensive system status
const status = await sdk.getSystemStatus();

Error Handling

The SDK provides comprehensive error handling:

try {
  const workflow = await sdk.workflows.create(data);
} catch (error) {
  if (error instanceof TriggerMeshSDKError) {
    console.error('API Error:', error.message);
    console.error('Status Code:', error.statusCode);
    console.error('Details:', error.details);
  } else {
    console.error('Unexpected error:', error);
  }
}

Response Handling

Standard Response Format

// All SDK methods return the data directly
const workflow = await sdk.workflows.create(data);
// workflow is the actual Workflow object

// For enhanced response handling, use requestWithResponse
const response = await sdk.client.requestWithResponse('workflow.create', data);
// response = { success: true, data: Workflow, meta: { timestamp, requestId, version } }

Paginated Responses

// List methods support pagination
const workflows = await sdk.workflows.getAll({
  limit: 10,
  offset: 0
});

Publishing the SDK

1. Update Version

npm version patch  # or minor/major

2. Build

npm run build

3. Publish

npm publish

4. Verify

npm view @trigger-mesh/sdk

Development

Setup

npm install
npm run build

Testing

npm test

Watch Mode

npm run dev

TypeScript Support

The SDK is written in TypeScript and provides full type definitions:

import { 
  TriggerMeshSDK, 
  Workflow, 
  Task, 
  CronJob,
  CreateWorkflowData 
} from '@trigger-mesh/sdk';

const sdk: TriggerMeshSDK = new TriggerMeshSDK(config);
const workflow: Workflow = await sdk.workflows.create(data);

Examples

See the examples/ directory for comprehensive usage examples:

  • Basic workflow creation and execution
  • Advanced scheduling with cron jobs
  • Webhook management
  • Error handling patterns
  • Workflow pack management

Support

License

MIT License - see LICENSE file for details.