import type { 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; /** * The on-the-wire form of an action's `outputSchema`, as accepted by the * `PublishComponent` mutation. JSON Schemas are serialized to strings and the * branching variant's per-branch map is flattened to a `{ name, schema }` * list (GraphQL input has no map type). Produced by `convertOutputSchema` * from the author-facing `OutputSchema`. */ outputSchema?: ServerOutputSchema; examplePerform?: ActionPerformFunction; examplePerformSafety?: PerformSafety; performSafety?: PerformSafety; } export type ServerOutputSchema = { type: "actionOutput"; schema: string; } | { type: "branchingOutput"; branchSchemas: Array<{ name: string; schema: string; }>; }; /** * On-the-wire form of the author-facing `PerformSafety`. The platform exposes * the field as the `ActionPerformSafety` GraphQL enum, which serializes member * names. Converted to and from the author-facing camelCase. */ export type PerformSafety = "SAFE" | "NOT_ALLOWED"; 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: TPayload; 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; /** * Wire format the platform expects for a trigger. Note: function references * (perform, resolveTriggerItems, getNextPaginationState, ...) don't survive JSON * serialization, so each callback has a paired `hasXxx: boolean` flag the * server reads to detect presence. Keep the flag and its callback in sync. * * The on-deploy fire is named asymmetrically by intent: CNI flow authors set * `onDeployTrigger` (sibling to `onTrigger`), component-trigger authors set * `onDeployPerform` (sibling to `perform`), and both flatten to * `onDeployPerform` here on the wire. */ 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; triggerResolverSupport?: TriggerOptionChoice; /** * The single default batch size shared by the trigger and on-deploy resolvers. The * platform reads only this field for both paths; there is no separate on-deploy default. */ triggerResolverDefaultBatchSize?: number; triggerResolverDefaultConcurrentBatchLimit?: number; resolveTriggerItems?: (context: ActionContext, result: TriggerBaseResult) => unknown[]; hasResolveTriggerItems?: boolean; getNextPaginationState?: (context: ActionContext, result: TriggerBaseResult) => Record | null; hasGetNextDiscoveryState?: boolean; onDeployPerform?: TriggerPerformFunction | PollingTriggerPerformFunction | CNIPollingPerformFunction | ComponentRefTriggerPerformFunction; hasOnDeployPerform?: boolean; resolveOnDeployItems?: (context: ActionContext, result: TriggerBaseResult) => unknown[]; hasResolveOnDeployItems?: boolean; getOnDeployNextPaginationState?: (context: ActionContext, result: TriggerBaseResult) => Record | null; hasGetOnDeployNextDiscoveryState?: boolean; 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; /** Nested children. For `structuredObject`, the declared inputs; for * `dynamicObject`, one `structuredObject` per configuration. */ inputs?: Input[]; } export * from "./asyncContext";