import { ComponentManifest, ConfigVarResultCollection, CustomerAttributes, DataSourceResultType, DataSourceType, DebugContext, ExecutionFrame, FlowAttributes, FlowInvoker, FlowSchemas, Inputs, InstanceAttributes, IntegrationAttributes, PollingTriggerPerformFunction, TriggerEventFunctionReturn, TriggerPerformFunction, TriggerResult as TriggerPerformResult, UserAttributes } from "../types"; import type { CNIPollingPerformFunction, ComponentRefTriggerPerformFunction } from "./triggerTypes"; interface DisplayDefinition { label: string; description: string; } export { CustomerAttributes, FlowAttributes, FlowSchemas, InstanceAttributes, IntegrationAttributes, UserAttributes, } from "../types"; export interface PublishingMetadata { flowsWithCustomerRequiredAPIKeys: { name: string; testApiKeys?: string[]; }[]; } export interface Component = TriggerPerformResult> { key: string; public?: boolean; documentationUrl?: string; display: DisplayDefinition & { category?: string; iconPath?: string; }; actions: Record; triggers: Record>; dataSources: Record; connections: Connection[]; codeNativeIntegrationYAML?: string; publishingMetadata?: PublishingMetadata; } export interface Action { key: string; display: DisplayDefinition & { directions?: string; important?: boolean; }; inputs: Input[]; terminateExecution?: boolean; breakLoop?: boolean; allowsBranching?: boolean; staticBranchNames?: string[]; dynamicBranchInput?: string; perform: ActionPerformFunction; examplePayload?: unknown; } export type ActionLoggerFunction = (...args: unknown[]) => void; export interface ActionLogger { metric: ActionLoggerFunction; trace: ActionLoggerFunction; debug: ActionLoggerFunction; info: ActionLoggerFunction; log: ActionLoggerFunction; warn: ActionLoggerFunction; error: ActionLoggerFunction; } export type ActionContext = Record, TFlows extends string[] = string[]> = { logger: ActionLogger; instanceState: Record; crossFlowState: Record; executionState: Record; integrationState: Record; configVars: TConfigVars; stepId: string; executionId: string; webhookUrls: Record; webhookApiKeys: Record; invokeUrl: string; customer: CustomerAttributes; instance: InstanceAttributes; user: UserAttributes; integration: IntegrationAttributes; flow: FlowAttributes; startedAt: string; executionFrame: ExecutionFrame; flowSchemas: FlowSchemas; globalDebug?: boolean; runnerAllocatedMemoryMb?: number; components: { [K in keyof TComponentActions]: { [A in keyof TComponentActions[K]]: TComponentActions[K][A]["perform"]; }; }; invokeFlow: FlowInvoker; debug: DebugContext; }; type TriggerOptionChoice = "invalid" | "valid" | "required"; export interface TriggerPayload { headers: Record; queryParameters: Record; rawBody: { data: unknown; contentType?: string; }; body: { data: unknown; contentType?: string; }; pathFragment: string; webhookUrls: Record; webhookApiKeys: Record; invokeUrl: string; executionId: string; customer: CustomerAttributes; instance: InstanceAttributes; user: UserAttributes; integration: IntegrationAttributes; flow: FlowAttributes; startedAt: string; globalDebug: boolean; } interface HttpResponse { statusCode: number; contentType: string; headers?: Record; body?: string; } interface TriggerBaseResult { payload: TriggerPayload; response?: HttpResponse; instanceState?: Record; crossFlowState?: Record; executionState?: Record; integrationState?: Record; failed?: boolean; error?: Record; } interface TriggerBranchingResult extends TriggerBaseResult { branch: string; } export type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined; export type TriggerEventFunctionResult = TriggerEventFunctionReturn | void; export type TriggerEventFunction = (context: ActionContext, params: Record) => Promise; export interface Trigger = TriggerPerformResult> { key: string; display: DisplayDefinition & { directions?: string; important?: boolean; }; inputs: Input[]; terminateExecution?: boolean; breakLoop?: boolean; allowsBranching?: boolean; staticBranchNames?: string[]; dynamicBranchInput?: string; perform: TriggerPerformFunction | PollingTriggerPerformFunction | CNIPollingPerformFunction | ComponentRefTriggerPerformFunction; onInstanceDeploy?: TriggerEventFunction; hasOnInstanceDeploy?: boolean; onInstanceDelete?: TriggerEventFunction; hasOnInstanceDelete?: boolean; webhookLifecycleHandlers?: { create: TriggerEventFunction; delete: TriggerEventFunction; }; webhookCreate?: TriggerEventFunction; hasWebhookCreateFunction?: boolean; webhookDelete?: TriggerEventFunction; hasWebhookDeleteFunction?: boolean; scheduleSupport: TriggerOptionChoice; synchronousResponseSupport: TriggerOptionChoice; examplePayload?: unknown; isCommonTrigger?: boolean; isPollingTrigger?: boolean; } export interface DataSourceContext { logger: ActionLogger; configVars: TConfigVars; customer: CustomerAttributes; instance: InstanceAttributes; user: UserAttributes; } export type DataSourceResult = { result: DataSourceResultType; supplementalData?: { data: unknown; contentType: string; }; }; export type DataSourcePerformFunction = (context: DataSourceContext, params: Record) => Promise; export interface DataSource { key: string; display: DisplayDefinition & { directions?: string; important?: boolean; }; inputs: Input[]; perform: DataSourcePerformFunction; dataSourceType: DataSourceType; examplePayload?: unknown; } export declare enum OAuth2Type { ClientCredentials = "client_credentials", AuthorizationCode = "authorization_code" } export interface Connection { key: string; label: string; comments?: string; oauth2Type?: OAuth2Type; iconPath?: string; avatarIconPath?: string; inputs: (Input & { shown?: boolean; onPremControlled?: boolean; })[]; } export interface ConnectionValue { key: string; configVarKey: string; fields: { [key: string]: unknown; }; token?: Record; context?: Record; } interface ServerPerformDataStructureReturn { data: boolean | number | string | Record | unknown[] | unknown; contentType?: string; statusCode?: number; headers?: Record; instanceState?: Record; crossFlowState?: Record; executionState?: Record; integrationState?: Record; failed?: boolean; error?: Record; } interface ServerPerformDataReturn { data: Buffer | string | unknown; contentType: string; statusCode?: number; headers?: Record; instanceState?: Record; crossFlowState?: Record; executionState?: Record; integrationState?: Record; failed?: boolean; error?: Record; } interface ServerPerformBranchingDataStructureReturn extends ServerPerformDataStructureReturn { branch: string; } interface ServerPerformBranchingDataReturn extends ServerPerformDataReturn { branch: string; } export type ActionPerformReturn = ServerPerformDataStructureReturn | ServerPerformBranchingDataStructureReturn | ServerPerformDataReturn | ServerPerformBranchingDataReturn | undefined; export type ActionPerformFunction = (context: ActionContext, params: Record) => Promise; interface InputFieldChoice { label: string; value: string; } export interface Input { key: string; label: string; keyLabel?: string; type: string; collection?: string; placeholder?: string; default?: unknown; comments?: string; example?: string; required?: boolean; model?: InputFieldChoice[]; language?: string; onPremiseControlled?: boolean; dataSource?: string; shown?: boolean; } export * from "./asyncContext";