Create a Connector
API reference for createConnector() — assembles auth, actions, and triggers into a frozen ConnectorDefinition.
Create a Connector
createConnector() is the top-level factory that assembles authentication, actions, and triggers into an immutable ConnectorDefinition.
Signature
import { createConnector } from "@triggo/connector-sdk";
function createConnector(config: ConnectorConfig): ConnectorDefinition;ConnectorConfig
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique connector identifier. Must be kebab-case (e.g., my-service). |
displayName | string | Yes | Human-readable name shown in the UI. |
description | string | Yes | Brief description of what the connector integrates with. |
auth | AuthDefinition | Yes | Authentication configuration. Use ConnectorAuth.OAuth2(), .SecretText(), .CustomAuth(), or .None(). |
actions | ActionDefinition[] | Yes | Array of actions created with createAction(). |
triggers | TriggerDefinition[] | Yes | Array of triggers created with createTrigger(). |
ConnectorDefinition (Return Type)
The returned object is deeply frozen and includes everything from the config plus computed fields:
| Field | Type | Description |
|---|---|---|
name | string | The kebab-case connector name. |
displayName | string | Human-readable name. |
description | string | Connector description. |
auth | AuthDefinition | The auth definition passed in. |
actions | readonly ActionDefinition[] | Frozen array of actions. |
triggers | readonly TriggerDefinition[] | Frozen array of triggers. |
actionsMap | ReadonlyMap<string, ActionDefinition> | Actions indexed by name for O(1) lookup. |
triggersMap | ReadonlyMap<string, TriggerDefinition> | Triggers indexed by name for O(1) lookup. |
schema | ConnectorSchema | Auto-generated JSON Schema for auth, action inputs, and trigger inputs. |
Validation Rules
createConnector() throws on invalid input:
- Name format -- must match
/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/(non-empty kebab-case) - Actions array -- must be an array (not null, not undefined)
- Triggers array -- must be an array (not null, not undefined)
- Duplicate action names -- throws if two actions share the same name
- Duplicate trigger names -- throws if two triggers share the same name
Example
import {
createConnector,
createAction,
createTrigger,
ConnectorAuth,
Property,
TRIGGER_TYPES,
} from "@triggo/connector-sdk";
const auth = ConnectorAuth.SecretText({
displayName: "API Key",
description: "Your service API key.",
});
const fetchItems = createAction({
name: "fetch_items",
displayName: "Fetch Items",
description: "Retrieves a list of items from the service.",
props: {
limit: Property.Number({
displayName: "Limit",
description: "Maximum number of items to return.",
required: false,
defaultValue: 10,
}),
},
async run(context) {
const limit = (context.propsValue.limit as number) ?? 10;
const secret = (context.auth as { secret: string }).secret;
const response = await fetch("https://api.example.com/items?limit=" + limit, {
headers: { Authorization: `Bearer ${secret}` },
});
return response.json();
},
});
export const exampleConnector = createConnector({
name: "example-service",
displayName: "Example Service",
description: "Integrates with Example Service API.",
auth,
actions: [fetchItems],
triggers: [],
});Auto-Generated Schema
The schema field on the returned definition contains JSON Schema representations of:
schema.auth-- auth fields schemaschema.actions-- each action's input schema, keyed by action nameschema.triggers-- each trigger's input schema, keyed by trigger name
These schemas are used by the AI system to understand connector capabilities during pipeline generation.
Immutability
The returned ConnectorDefinition and all nested objects are deeply frozen via Object.freeze(). This prevents accidental mutation at runtime and ensures connectors remain stable across concurrent pipeline executions.