import type { ActionDefinition } from "./ActionDefinition"; import type { ConnectionDefinition } from "./ConnectionDefinition"; import type { DataSourceDefinition } from "./DataSourceDefinition"; import type { ComponentDisplayDefinition } from "./DisplayDefinition"; import type { PollingTriggerDefinition } from "./PollingTriggerDefinition"; import type { TriggerDefinition } from "./TriggerDefinition"; export type ErrorHandler = (error: unknown) => unknown | Promise; export interface ComponentHooks { /** * Defines a global error handler that automatically wraps the component's action/trigger * perform functions. See * https://prismatic.io/docs/custom-connectors/error-handling/#global-error-handlers */ error?: ErrorHandler; } /** Defines attributes of a component. */ export type ComponentDefinition = { /** Specifies a unique programmatic key for this component. */ key: TKey; /** * Specifies if this component is available for all organizations or only your own. * Only Prismatic public components can specify 'true' * @default false */ public?: TPublic; /** Defines how the component is displayed in the Prismatic UI. */ display: ComponentDisplayDefinition; /** * Specifies the supported Actions of this component. See * https://prismatic.io/docs/custom-connectors/actions/ */ actions?: Record>; /** * Specifies the supported triggers of this component. See * https://prismatic.io/docs/custom-connectors/triggers/ */ triggers?: Record | PollingTriggerDefinition>; /** * Specifies the supported data sources of this component. See * https://prismatic.io/docs/custom-connectors/data-sources/ */ dataSources?: Record>; /** * Specifies the supported connections of this component. See * https://prismatic.io/docs/custom-connectors/connections/ */ connections?: ConnectionDefinition[]; /** * Hooks (error handler) for this component. See * https://prismatic.io/docs/custom-connectors/error-handling/ */ hooks?: ComponentHooks; } & (TPublic extends true ? { /** The URL for this component's documentation. */ documentationUrl: `https://prismatic.io/docs/components/${TKey}/`; } : { documentationUrl?: string; });