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

@dev-fastn-ai/core

v2.0.9

Published

Framework-agnostic TypeScript SDK for Fastn AI platform. Provides core functionality for managing connectors, configurations, and integrations.

Readme

@fastn-ai/core

A framework-agnostic TypeScript SDK for the Fastn AI platform. This package provides the core functionality for managing connectors, configurations, and integrations with full TypeScript support.

🚀 Features

  • 🔌 Connector Management: Fetch and manage marketplace connectors
  • ⚙️ Configuration Handling: Create, update, and manage connector configurations
  • 📝 Form Management: Handle dynamic configuration forms
  • 🔄 Real-time Updates: Built-in caching and background refetching
  • 📱 TypeScript First: Complete type safety and IntelliSense support
  • 🌐 Framework Agnostic: Works with any JavaScript/TypeScript framework

📦 Installation

npm install @fastn-ai/core

🏗️ Quick Start

Basic Usage

import { Fastn } from '@fastn-ai/core';

// Initialize the SDK
const fastn = new Fastn({
  environment: 'LIVE',
  authToken: 'your-auth-token',
  tenantId: 'your-tenant-id',
  spaceId: 'your-space-id',
});

// Fetch connectors
const connectors = await fastn.getConnectors();

// Fetch configurations
const configurations = await fastn.getConfigurations({
  configurationId: 'your-configuration-id',
  status: 'ALL'
});

// Get configuration form
const form = await fastn.getConfigurationForm({
  configurationId: 'your-configuration-id',
  connectorId: 'your-connector-id',
  configuration: configurationData
});

📚 API Reference

Fastn Class

The main class for interacting with the Fastn AI platform.

Constructor

new Fastn(config: Required<FastnConfig>)

Configuration

interface FastnConfig {
  baseUrl?: string;
  environment?: FastnEnvironment;
  authToken: string;
  tenantId: string;
  spaceId: string;
  customAuth?: boolean;
}

type FastnEnvironment = 'LIVE' | 'DRAFT' | string;

Methods

getConnectors(input?: GetConnectorsInput): Promise<Connector[]>

Fetches available connectors from the marketplace.

interface GetConnectorsInput {
  disabled?: boolean;
  status?: ConnectorStatus;
  refetch?: () => Promise<any>;
}
getConfigurations(input: GetConfigurationsInput): Promise<Configuration[]>

Fetches connector configurations.

interface GetConfigurationsInput {
  configurationId: string;
  status?: "ENABLED" | "DISABLED" | "ALL" | "IDLE";
}
getConfigurationForm(input: GetConfigurationFormInput): Promise<ConfigurationForm>

Fetches configuration forms for setting up connectors.

interface GetConfigurationFormInput {
  configurationId: string;
  connectorId: string;
  configuration: Configuration;
}
registerRefetchFunction(input: RegisterRefetchFunctionInput): void

Registers a function to be called when data needs to be refetched.

interface RegisterRefetchFunctionInput {
  refetchFunction: () => Promise<void>;
  refetchKey: string;
}

🎯 Type Definitions

Core Types

interface Connector {
  readonly id: string;
  readonly name: string;
  readonly description: string;
  readonly imageUri?: string;
  readonly status: ConnectorStatus;
  readonly actions: readonly ConnectorAction[];
}

interface Configuration {
  readonly id: string;
  readonly connectorId: string;
  readonly configurationId: string;
  readonly name: string;
  readonly flowId: string;
  readonly description: string;
  readonly imageUri: string;
  readonly status: string;
  readonly actions: readonly ConfigurationAction[];
  readonly metadata?: Record<string, Record<string, Primitive>> |  Record<string, Record<string, Primitive>>[] | undefined | null;
}

interface ConfigurationForm {
  readonly name: string;
  readonly description: string;
  readonly imageUri: string;
  readonly fields: readonly ConnectorField[];
  readonly submitButtonLabel?: string;
  readonly loading?: boolean;
  readonly error?: string;
  readonly submitHandler?: (args: { formData: FormData }) => Promise<void>;
}

Enums

enum ConnectorStatus {
  ACTIVE = "ACTIVE",
  INACTIVE = "INACTIVE",
  ALL = "ALL",
}

enum ConnectorActionType {
  ACTIVATION = "ACTIVATION",
  DEACTIVATION = "DEACTIVATION",
  NONE = "NONE",
  ENABLE = "ENABLE",
  DISABLE = "DISABLE",
  DELETE = "DELETE",
}

enum ConnectorFieldType {
  TEXT = "text",
  NUMBER = "number",
  CHECKBOX = "checkbox",
  DATE = "date",
  DATETIME = "datetime",
  TIME = "time",
  DATETIME_LOCAL = "datetime-local",
  MULTI_SELECT = "multi-select",
  SELECT = "select",
}

🛠️ Error Handling

The SDK provides comprehensive error handling with custom error classes:

import {
  FastnError,
  MissingConfigError,
  AuthenticationError,
  MissingAuthTokenError,
  MissingSpaceIdError,
  MissingTenantIdError,
} from '@fastn-ai/core';

try {
  const connectors = await fastn.getConnectors();
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error('Authentication failed:', error.message);
  } else if (error instanceof MissingConfigError) {
    console.error('Configuration missing:', error.message);
  }
}

🔧 Advanced Usage

Custom Authentication

const fastn = new Fastn({
  baseUrl: 'https://api.fastn.ai',
  environment: 'LIVE',
  authToken: 'your-auth-token',
  tenantId: 'your-tenant-id',
  spaceId: 'your-space-id',
  customAuth: true, // Enable custom authentication
});

Error Boundaries

class FastnErrorHandler {
  static handle(error: FastnError) {
    switch (error.code) {
      case 'AUTH_ERROR':
        // Handle authentication errors
        break;
      case 'MISSING_CONFIG':
        // Handle configuration errors
        break;
      default:
        // Handle other errors
        console.error('Fastn error:', error.message);
    }
  }
}

🎯 Best Practices

1. Configuration Management

// Store configuration securely
const config = {
  baseUrl: FASTN_BASE_URL || 'https://api.fastn.ai',
  environment: FASTN_ENVIRONMENT || 'LIVE',
  authToken: FASTN_AUTH_TOKEN!,
  tenantId: FASTN_TENANT_ID!,
  spaceId: FASTN_SPACE_ID!,
  customAuth: FASTN_CUSTOM_AUTH === 'true',
};

const fastn = new Fastn(config);

2. Error Handling

async function fetchConnectors() {
  try {
    return await fastn.getConnectors();
  } catch (error) {
    if (error instanceof FastnError) {
      // Handle Fastn-specific errors
      console.error(`Fastn error (${error.code}):`, error.message);
    } else {
      // Handle other errors
      console.error('Unexpected error:', error);
    }
    throw error;
  }
}

3. Type Safety

import type {
  Connector,
  Configuration,
  ConnectorAction,
  ConfigurationAction,
} from '@fastn-ai/core';

function handleConnectorAction(connector: Connector, action: ConnectorAction) {
  if (action.actionType === ConnectorActionType.ACTIVATION) {
    // Handle activation
  } else if (action.actionType === ConnectorActionType.DEACTIVATION) {
    // Handle deactivation
  }
}

🐛 Troubleshooting

Common Issues

1. Authentication Errors

Error: AuthenticationError: Authentication failed

Solution: Verify your authToken is valid and not expired.

2. Configuration Errors

Error: MissingConfigError: Config is missing

Solution: Ensure all required configuration properties are provided.

3. Network Errors

Error: Network Error or Failed to fetch

Solution: Check your baseUrl and network connectivity.

Debug Mode

Enable debug logging to troubleshoot issues:

if (NODE_ENV === 'development') {
  console.log('Fastn Config:', config);
}

📚 Additional Resources

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

If you need help or have questions:


Made with ❤️ by the Fastn AI team