TypeScript types for Pipedream components (sources and actions)
npx @tessl/cli install tessl/npm-pipedream--types@0.3.0@pipedream/types provides comprehensive TypeScript type definitions for Pipedream's component development ecosystem. It enables developers to build type-safe Pipedream components including event sources and actions by providing interfaces, type definitions, and schemas that cover the complete component API structure.
npm install @pipedream/typesimport { PipedreamComponent, ComponentProps, TimerInterface, HttpInterface } from "@pipedream/types";For importing specific type categories:
import {
// Component structure
PipedreamComponent, PipedreamApp,
// Props and interfaces
UserInputProp, ComponentProps, TimerInterface, HttpInterface,
// Events and context
ComponentThis, EmitMethod, EventMetadata,
// Utilities
DedupeStrategy, AuthContext
} from "@pipedream/types";import { PipedreamComponent, ComponentProps, TimerInterface } from "@pipedream/types";
// Define a basic timer-based component
const component: PipedreamComponent = {
key: "example-timer-component",
name: "Example Timer Component",
version: "0.0.1",
description: "An example component that runs on a timer",
props: {
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: 60 * 15, // 15 minutes
},
},
db: "$.service.db",
},
async run(event) {
// Access typed context
const { timer, db, $emit } = this;
// Emit typed events
this.$emit({ message: "Timer triggered" }, {
id: Date.now(),
summary: "Timer execution",
ts: Date.now(),
});
},
};@pipedream/types is organized around several key type systems:
PipedreamComponent, PipedreamApp)TimerInterface, HttpInterface, AppHookInterface)ComponentThis, AuthContext)EmitMethod, EventMetadata)Core interfaces and types for defining Pipedream components, including the main component interface, app definitions, and lifecycle hooks.
interface PipedreamComponent {
key?: string;
name: string;
version: string;
description?: string;
props: ComponentProps;
methods?: ComponentMethods;
hooks?: ComponentHooks;
dedupe?: DedupeStrategy;
run: (event: any) => Promise<void> | void;
}
interface PipedreamApp {
type: "app";
app: string;
propDefinitions?: PropDefinitions;
methods?: AppMethods;
}Comprehensive type system for component properties including user input props, validation schemas, and dynamic option loading.
interface UserInputProp {
type: PropType;
label?: string;
description?: string;
optional?: boolean;
default?: any;
secret?: boolean;
options?: PropOptions;
useQuery?: boolean;
propDefinition?: [PipedreamApp, string, any?];
appProp?: string;
baseIdProp?: string;
tableIdProp?: string;
}
type PropType =
| "string" | "boolean" | "integer" | "app"
| "string[]" | "boolean[]" | "integer[]"
| "$.airtable.baseId" | "$.airtable.tableId" | "$.airtable.viewId";Strongly typed interfaces for component triggers including timer-based execution, HTTP endpoints, and app webhooks.
interface TimerInterface {
type: "$.interface.timer";
default?: {
intervalSeconds?: number;
cron?: string;
};
}
interface HttpInterface {
type: "$.interface.http";
customResponse?: boolean;
respond?: HttpRespondMethod;
}
interface AppHookInterface {
type: "$.interface.apphook";
appProp: string;
eventNames: string[];
}Types for event emission, metadata, and deduplication strategies used throughout the Pipedream component lifecycle.
interface EmitMethod {
(event: any, metadata?: EventMetadata): void;
}
interface EventMetadata {
id?: string | number;
summary?: string;
ts?: number;
}
type DedupeStrategy = "unique" | "greatest" | "last";Runtime context types available during component execution, including access to props, services, and authentication.
interface ComponentThis {
[propName: string]: any;
$emit: EmitMethod;
$auth?: AuthContext;
db?: DatabaseService;
http?: HttpEndpoint & { respond: HttpRespondMethod };
}
interface AuthContext {
oauth_access_token?: string;
oauth_refresh_token?: string;
api_key?: string;
[key: string]: any;
}Type definitions for Pipedream's built-in services including database storage and HTTP response handling.
interface DatabaseService {
type: "$.service.db";
get: (key: string) => any;
set: (key: string, value: any) => void;
}
interface HttpRespondMethod {
(response: {
status: number;
headers?: Record<string, string>;
body?: string | object | Buffer;
}): void;
}