Connector SDK
The Connector SDK provides a BaseConnector abstract class for building your own destination connectors.
Installation
Section titled “Installation”npm install @uniflow/connector-sdkCreating a connector
Section titled “Creating a connector”Extend BaseConnector and implement the required metadata and handle() method:
import { BaseConnector, type ConnectorEvent, type ConnectorResult,} from '@uniflow/connector-sdk';import { z } from 'zod';
// Define your connector's config schemaconst ConfigSchema = z.object({ apiKey: z.string(), endpoint: z.string().url(),});
type Config = z.infer<typeof ConfigSchema>;
export class MyConnector extends BaseConnector<Config> { readonly metadata = { id: 'my-connector', name: 'My Service', description: 'Send events to My Service', configSchema: ConfigSchema, };
async handle( event: ConnectorEvent, config: Config, ): Promise<ConnectorResult> { const response = await fetch(config.endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${config.apiKey}`, }, body: JSON.stringify(event), });
if (!response.ok) { return { success: false, error: `HTTP ${response.status}`, }; }
return { success: true }; }}BaseConnector API
Section titled “BaseConnector API”metadata (required)
Section titled “metadata (required)”| Property | Type | Description |
|---|---|---|
id | string | Unique connector identifier |
name | string | Human-readable name |
description | string | Short description |
configSchema | ZodSchema | Zod schema for config validation |
handle(event, config) (required)
Section titled “handle(event, config) (required)”Called for each event routed to this destination. Must return a ConnectorResult:
interface ConnectorResult { success: boolean; error?: string;}parseConfig(raw) (inherited)
Section titled “parseConfig(raw) (inherited)”Validates raw config from the Admin UI against your configSchema. Called automatically — you don’t need to override this.
const config = connector.parseConfig(rawConfigFromDB);// Throws ZodError if invalidPublishing
Section titled “Publishing”Name your package @uniflow/connector-<name> and publish to npm. Then add it to your uniflow.config.yaml:
connectors: - webhook - s3-export - my-connectorThe connector will be automatically picked up during uniflow deploy.