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

@almadar/integrations

v1.0.15

Published

External service integrations for Almadar applications

Readme

@almadar/integrations

External service integrations for Almadar applications

Production-ready implementations of external service integrations that work seamlessly in both interpreted runtime and compiled applications.

Features

  • Type-Safe - Full TypeScript types from registry to implementation
  • Environment-Agnostic - Works in runtime AND compiled apps
  • Testable - Mock implementations for testing
  • Extensible - Easy to add new integrations
  • Secure - API keys via environment variables
  • Observable - Logging and error tracking
  • Validated - Input validation against registry schema

Supported Integrations

| Integration | Actions | Use Case | |-------------|---------|----------| | Stripe | createPaymentIntent, confirmPayment, refund | Payment processing | | YouTube | search, getVideo, getChannel | Video data and search | | Twilio | sendSMS, sendWhatsApp | Messaging | | Email | send | Transactional email (SendGrid/Resend) | | LLM | generate, classify, extract, summarize | AI content generation | | DeepAgent | sendMessage, validateSchema, compileSchema | AI code generation |

Installation

pnpm add @almadar/integrations

Usage

1. Runtime Integration

Use with @almadar/runtime:

import { RuntimeIntegrationManager } from '@almadar/integrations/runtime';
import '@almadar/integrations'; // Auto-register integrations

const integrationManager = new RuntimeIntegrationManager();
integrationManager.configureFromEnv();

const runtime = new OrbitalServerRuntime({
  schema,
  effectHandlers: {
    callService: integrationManager.getCallServiceHandler(),
    // ... other handlers
  },
});

2. Compiled App

Use in generated code:

import { IntegrationFactory } from '@almadar/integrations';
import '@almadar/integrations'; // Auto-register integrations

const integrations = new IntegrationFactory();

// Configure integrations
integrations.configure('stripe', {
  env: {
    STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY!,
  },
});

// Use in effect handler
async function handleCallService(service, action, params) {
  const result = await integrations.execute(service, action, params);
  
  if (!result.success) {
    throw result.error;
  }
  
  return result.data;
}

3. Direct Usage

Use integrations directly:

import { StripeIntegration } from '@almadar/integrations';

const stripe = new StripeIntegration({
  name: 'stripe',
  env: {
    STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY!,
  },
});

const result = await stripe.execute('createPaymentIntent', {
  amount: 2000,
  currency: 'usd',
});

if (result.success) {
  console.log('Payment intent:', result.data);
}

Configuration

Set environment variables:

# Stripe
STRIPE_SECRET_KEY=sk_test_...

# YouTube
YOUTUBE_API_KEY=AIza...

# Twilio
TWILIO_ACCOUNT_SID=AC...
TWILIO_AUTH_TOKEN=...
TWILIO_PHONE_NUMBER=+1...

# Email (SendGrid)
SENDGRID_API_KEY=SG....
[email protected]

# Email (Resend)
RESEND_API_KEY=re_...

# LLM (Anthropic)
ANTHROPIC_API_KEY=sk-ant-...

# LLM (OpenAI)
OPENAI_API_KEY=sk-...

# DeepAgent
DEEPAGENT_API_URL=http://localhost:3000
DEEPAGENT_API_KEY=...

Testing

Use mock implementations:

import { MockIntegrationFactory } from '@almadar/integrations/mocks';

const mockFactory = new MockIntegrationFactory();

// Set mock response
mockFactory.setMockResponse('stripe', 'createPaymentIntent', {
  id: 'pi_test_123',
  clientSecret: 'secret_test_123',
  status: 'succeeded',
});

// Execute
const result = await mockFactory.execute('stripe', 'createPaymentIntent', {
  amount: 2000,
  currency: 'usd',
});

// Assert
expect(result.success).toBe(true);
expect(result.data).toHaveProperty('id');

// Check calls
const calls = mockFactory.getMockCalls('stripe');
expect(calls).toHaveLength(1);
expect(calls[0].action).toBe('createPaymentIntent');

Schema Usage

In .orb files, use call-service effect:

{
  "transitions": [{
    "from": "idle",
    "to": "processing",
    "event": "CHECKOUT",
    "effects": [
      ["call-service", "stripe", "createPaymentIntent", {
        "amount": "@payload.amount",
        "currency": "@payload.currency"
      }]
    ]
  }]
}

API

IntegrationFactory

const factory = new IntegrationFactory();

// Configure an integration
factory.configure('stripe', {
  env: { STRIPE_SECRET_KEY: '...' },
  timeout: 30000,
  retry: { maxAttempts: 3, backoffMs: 1000 }
});

// Execute an action
const result = await factory.execute('stripe', 'createPaymentIntent', params);

// Get integration instance
const stripe = factory.get('stripe');

RuntimeIntegrationManager

const manager = new RuntimeIntegrationManager();

// Auto-configure from environment
manager.configureFromEnv();

// Get effect handler
const callServiceHandler = manager.getCallServiceHandler();

// Get factory
const factory = manager.getFactory();

BaseIntegration

Extend for custom integrations:

import { BaseIntegration } from '@almadar/integrations';

class MyIntegration extends BaseIntegration {
  async execute(action, params) {
    const validation = this.validateParams(action, params);
    if (!validation.valid) {
      return { success: false, error: ... };
    }
    
    // Implement your logic
    const data = await this.myApiCall(params);
    
    return {
      success: true,
      data,
      metadata: this.createMetadata(action, duration)
    };
  }
}

Architecture

┌─────────────────────────────────────────────────────────────┐
│                     .orb Schema File                         │
│  ["call-service", "stripe", "createPaymentIntent", {...}]    │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│           @almadar/patterns (Registry)                       │
│  integrators-registry.json - Defines actions & params        │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│         @almadar/integrations (THIS PACKAGE)                 │
│  - SDK wrappers                                              │
│  - Auth handling                                             │
│  - Error handling                                            │
│  - Type-safe implementations                                 │
└──────────────────────────────┬──────────────────────────────┘
                               │
                               ▼
┌─────────────────────────────────────────────────────────────┐
│              Runtime / Compiled App                          │
│  - @almadar/runtime (interpreted)                            │
│  - Generated TypeScript/Python code (compiled)               │
└─────────────────────────────────────────────────────────────┘

License

MIT