- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
256 lines
7.0 KiB
TypeScript
256 lines
7.0 KiB
TypeScript
import { Static, Type } from '@sinclair/typebox'
|
|
import { ExecutionToolStatus } from '../agents'
|
|
import { AppConnectionValue } from '../app-connection/app-connection'
|
|
import { ExecutionState, ExecutionType, ResumePayload } from '../flow-run/execution/execution-output'
|
|
import { FlowRunId, RunEnvironment } from '../flow-run/flow-run'
|
|
import { FlowVersion } from '../flows/flow-version'
|
|
import { PiecePackage } from '../pieces'
|
|
import { PlatformId } from '../platform'
|
|
import { ProjectId } from '../project/project'
|
|
import { ScheduleOptions } from '../trigger'
|
|
|
|
export enum EngineOperationType {
|
|
EXTRACT_PIECE_METADATA = 'EXTRACT_PIECE_METADATA',
|
|
EXECUTE_FLOW = 'EXECUTE_FLOW',
|
|
EXECUTE_PROPERTY = 'EXECUTE_PROPERTY',
|
|
EXECUTE_TRIGGER_HOOK = 'EXECUTE_TRIGGER_HOOK',
|
|
EXECUTE_VALIDATE_AUTH = 'EXECUTE_VALIDATE_AUTH',
|
|
}
|
|
|
|
export enum TriggerHookType {
|
|
ON_ENABLE = 'ON_ENABLE',
|
|
ON_DISABLE = 'ON_DISABLE',
|
|
HANDSHAKE = 'HANDSHAKE',
|
|
RENEW = 'RENEW',
|
|
RUN = 'RUN',
|
|
TEST = 'TEST',
|
|
}
|
|
|
|
export type EngineOperation =
|
|
| ExecuteToolOperation
|
|
| ExecuteFlowOperation
|
|
| ExecutePropsOptions
|
|
| ExecuteTriggerOperation<TriggerHookType>
|
|
| ExecuteExtractPieceMetadataOperation
|
|
| ExecuteValidateAuthOperation
|
|
|
|
export const enum EngineSocketEvent {
|
|
ENGINE_RESPONSE = 'engine-response',
|
|
ENGINE_STDOUT = 'engine-stdout',
|
|
ENGINE_STDERR = 'engine-stderr',
|
|
ENGINE_READY = 'engine-ready',
|
|
ENGINE_OPERATION = 'engine-operation',
|
|
UPDATE_RUN_PROGRESS = 'update-run-progress',
|
|
SEND_FLOW_RESPONSE = 'send-flow-response',
|
|
UPDATE_STEP_PROGRESS = 'update-step-progress',
|
|
}
|
|
|
|
|
|
export const EngineStdout = Type.Object({
|
|
message: Type.String(),
|
|
})
|
|
|
|
export const EngineStderr = Type.Object({
|
|
message: Type.String(),
|
|
})
|
|
|
|
|
|
export type EngineStdout = Static<typeof EngineStdout>
|
|
export type EngineStderr = Static<typeof EngineStderr>
|
|
|
|
|
|
export type BaseEngineOperation = {
|
|
projectId: ProjectId
|
|
engineToken: string
|
|
internalApiUrl: string
|
|
publicApiUrl: string
|
|
timeoutInSeconds: number
|
|
platformId: PlatformId
|
|
}
|
|
|
|
export type ExecuteValidateAuthOperation = Omit<BaseEngineOperation, 'projectId'> & {
|
|
piece: PiecePackage
|
|
auth: AppConnectionValue
|
|
}
|
|
|
|
export type ExecuteExtractPieceMetadata = PiecePackage & { platformId: PlatformId }
|
|
|
|
export type ExecuteExtractPieceMetadataOperation = ExecuteExtractPieceMetadata & { timeoutInSeconds: number, platformId: PlatformId }
|
|
|
|
export type ExecuteToolOperation = BaseEngineOperation & {
|
|
actionName: string
|
|
pieceName: string
|
|
pieceVersion: string
|
|
predefinedInput: Record<string, unknown>
|
|
instruction: string
|
|
}
|
|
|
|
export type ExecutePropsOptions = BaseEngineOperation & {
|
|
piece: PiecePackage
|
|
propertyName: string
|
|
actionOrTriggerName: string
|
|
flowVersion?: FlowVersion
|
|
input: Record<string, unknown>
|
|
sampleData: Record<string, unknown>
|
|
searchValue?: string
|
|
}
|
|
|
|
type BaseExecuteFlowOperation<T extends ExecutionType> = BaseEngineOperation & {
|
|
flowVersion: FlowVersion
|
|
flowRunId: FlowRunId
|
|
executionType: T
|
|
runEnvironment: RunEnvironment
|
|
executionState: ExecutionState
|
|
serverHandlerId: string | null
|
|
httpRequestId: string | null
|
|
progressUpdateType: ProgressUpdateType
|
|
stepNameToTest: string | null
|
|
sampleData?: Record<string, unknown>
|
|
logsUploadUrl?: string
|
|
logsFileId?: string
|
|
}
|
|
|
|
export enum ProgressUpdateType {
|
|
WEBHOOK_RESPONSE = 'WEBHOOK_RESPONSE',
|
|
TEST_FLOW = 'TEST_FLOW',
|
|
NONE = 'NONE',
|
|
}
|
|
|
|
export type BeginExecuteFlowOperation = BaseExecuteFlowOperation<ExecutionType.BEGIN> & {
|
|
triggerPayload: unknown
|
|
executeTrigger: boolean
|
|
}
|
|
|
|
export type ResumeExecuteFlowOperation = BaseExecuteFlowOperation<ExecutionType.RESUME> & {
|
|
resumePayload: ResumePayload
|
|
}
|
|
|
|
export type ExecuteFlowOperation = BeginExecuteFlowOperation | ResumeExecuteFlowOperation
|
|
|
|
|
|
export type ExecuteTriggerOperation<HT extends TriggerHookType> = BaseEngineOperation & {
|
|
hookType: HT
|
|
test: boolean
|
|
flowVersion: FlowVersion
|
|
webhookUrl: string
|
|
triggerPayload?: TriggerPayload
|
|
appWebhookUrl?: string
|
|
webhookSecret?: string | Record<string, string>
|
|
}
|
|
|
|
|
|
export const TriggerPayload = Type.Object({
|
|
body: Type.Unknown(),
|
|
rawBody: Type.Optional(Type.Unknown()),
|
|
headers: Type.Record(Type.String(), Type.String()),
|
|
queryParams: Type.Record(Type.String(), Type.String()),
|
|
})
|
|
|
|
export type TriggerPayload<T = unknown> = {
|
|
body: T
|
|
rawBody?: unknown
|
|
headers: Record<string, string>
|
|
queryParams: Record<string, string>
|
|
}
|
|
|
|
export type EventPayload<B = unknown> = {
|
|
body: B
|
|
rawBody?: unknown
|
|
method: string
|
|
headers: Record<string, string>
|
|
queryParams: Record<string, string>
|
|
}
|
|
|
|
export type ParseEventResponse = {
|
|
event?: string
|
|
identifierValue?: string
|
|
reply?: {
|
|
headers: Record<string, string>
|
|
body: unknown
|
|
}
|
|
}
|
|
|
|
export type AppEventListener = {
|
|
events: string[]
|
|
identifierValue: string
|
|
}
|
|
|
|
|
|
type ExecuteTestOrRunTriggerResponse = {
|
|
success: boolean
|
|
message?: string
|
|
output: unknown[]
|
|
}
|
|
|
|
type ExecuteHandshakeTriggerResponse = {
|
|
success: boolean
|
|
message?: string
|
|
response?: {
|
|
status: number
|
|
body?: unknown
|
|
headers?: Record<string, string>
|
|
}
|
|
}
|
|
|
|
type ExecuteOnEnableTriggerResponse = {
|
|
listeners: AppEventListener[]
|
|
scheduleOptions?: ScheduleOptions
|
|
}
|
|
|
|
export const EngineHttpResponse = Type.Object({
|
|
status: Type.Number(),
|
|
body: Type.Unknown(),
|
|
headers: Type.Record(Type.String(), Type.String()),
|
|
})
|
|
|
|
export type EngineHttpResponse = Static<typeof EngineHttpResponse>
|
|
|
|
export type ExecuteTriggerResponse<H extends TriggerHookType> = H extends TriggerHookType.RUN ? ExecuteTestOrRunTriggerResponse :
|
|
H extends TriggerHookType.HANDSHAKE ? ExecuteHandshakeTriggerResponse :
|
|
H extends TriggerHookType.TEST ? ExecuteTestOrRunTriggerResponse :
|
|
H extends TriggerHookType.RENEW ? Record<string, never> :
|
|
H extends TriggerHookType.ON_DISABLE ? Record<string, never> :
|
|
ExecuteOnEnableTriggerResponse
|
|
|
|
export type ExecuteToolResponse = {
|
|
status: ExecutionToolStatus
|
|
output?: unknown
|
|
resolvedInput: Record<string, unknown>
|
|
errorMessage?: unknown
|
|
}
|
|
|
|
export type ExecuteActionResponse = {
|
|
success: boolean
|
|
input: unknown
|
|
output: unknown
|
|
message?: string
|
|
}
|
|
|
|
type BaseExecuteValidateAuthResponseOutput<Valid extends boolean> = {
|
|
valid: Valid
|
|
}
|
|
|
|
type ValidExecuteValidateAuthResponseOutput = BaseExecuteValidateAuthResponseOutput<true>
|
|
|
|
type InvalidExecuteValidateAuthResponseOutput = BaseExecuteValidateAuthResponseOutput<false> & {
|
|
error: string
|
|
}
|
|
export type ExecuteValidateAuthResponse =
|
|
| ValidExecuteValidateAuthResponseOutput
|
|
| InvalidExecuteValidateAuthResponseOutput
|
|
|
|
|
|
export type EngineResponse<T = unknown> = {
|
|
status: EngineResponseStatus
|
|
response: T
|
|
delayInSeconds?: number
|
|
error?: string
|
|
}
|
|
|
|
export enum EngineResponseStatus {
|
|
OK = 'OK',
|
|
INTERNAL_ERROR = 'INTERNAL_ERROR',
|
|
TIMEOUT = 'TIMEOUT',
|
|
MEMORY_ISSUE = 'MEMORY_ISSUE',
|
|
}
|