diff --git a/packages/engine/src/lib/handler/context/flow-execution-context.ts b/packages/engine/src/lib/handler/context/flow-execution-context.ts index d6e81bbc19..ff113c5300 100644 --- a/packages/engine/src/lib/handler/context/flow-execution-context.ts +++ b/packages/engine/src/lib/handler/context/flow-execution-context.ts @@ -1,8 +1,7 @@ -import { ActionType, LoopStepOutput, PauseMetadata, StepOutput, StepOutputStatus, StopResponse, assertEqual, isNil } from '@activepieces/shared' +import { ActionType, FlowRunResponse, FlowRunStatus, LoopStepOutput, PauseMetadata, StepOutput, StepOutputStatus, StopResponse, assertEqual, isNil } from '@activepieces/shared' import { StepExecutionPath } from './step-execution-path' import { loggingUtils } from '../../helper/logging-utils' import { nanoid } from 'nanoid' -import { FlowExecutionResponse, FlowExecutionStatus } from '@activepieces/shared' export enum ExecutionVerdict { RUNNING = 'RUNNING', @@ -12,10 +11,10 @@ export enum ExecutionVerdict { } type VerdictResponse = { - reason: FlowExecutionStatus.PAUSED + reason: FlowRunStatus.PAUSED pauseMetadata: PauseMetadata } | { - reason: FlowExecutionStatus.STOPPED + reason: FlowRunStatus.STOPPED stopResponse: StopResponse } @@ -166,7 +165,7 @@ export class FlowExecutorContext { }) } - public async toResponse(): Promise { + public async toResponse(): Promise { const baseExecutionOutput = { duration: this.duration, tasks: this.tasks, @@ -177,32 +176,32 @@ export class FlowExecutorContext { case ExecutionVerdict.FAILED: return { ...baseExecutionOutput, - status: FlowExecutionStatus.FAILED, + status: FlowRunStatus.FAILED, } case ExecutionVerdict.PAUSED: { const verdictResponse = this.verdictResponse - if (verdictResponse?.reason !== FlowExecutionStatus.PAUSED) { + if (verdictResponse?.reason !== FlowRunStatus.PAUSED) { throw new Error('Verdict Response should have pause metadata response') } return { ...baseExecutionOutput, - status: FlowExecutionStatus.PAUSED, + status: FlowRunStatus.PAUSED, pauseMetadata: verdictResponse.pauseMetadata, } } case ExecutionVerdict.RUNNING: case ExecutionVerdict.SUCCEEDED: { const verdictResponse = this.verdictResponse - if (verdictResponse?.reason === FlowExecutionStatus.STOPPED) { + if (verdictResponse?.reason === FlowRunStatus.STOPPED) { return { ...baseExecutionOutput, - status: FlowExecutionStatus.STOPPED, + status: FlowRunStatus.STOPPED, stopResponse: verdictResponse.stopResponse, } } return { ...baseExecutionOutput, - status: FlowExecutionStatus.SUCCEEDED, + status: FlowRunStatus.SUCCEEDED, } } } diff --git a/packages/engine/src/lib/handler/piece-executor.ts b/packages/engine/src/lib/handler/piece-executor.ts index c3e362a32c..9e7cfae6dd 100644 --- a/packages/engine/src/lib/handler/piece-executor.ts +++ b/packages/engine/src/lib/handler/piece-executor.ts @@ -1,4 +1,4 @@ -import { AUTHENTICATION_PROPERTY_NAME, GenericStepOutput, ActionType, PieceAction, StepOutputStatus, assertNotNullOrUndefined, isNil, ExecutionType, PauseType, FlowExecutionStatus } from '@activepieces/shared' +import { AUTHENTICATION_PROPERTY_NAME, GenericStepOutput, ActionType, PieceAction, StepOutputStatus, assertNotNullOrUndefined, isNil, ExecutionType, PauseType, FlowRunStatus } from '@activepieces/shared' import { ActionHandler, BaseExecutor } from './base-executor' import { ExecutionVerdict, FlowExecutorContext } from './context/flow-execution-context' import { ActionContext, ConnectionsManager, PauseHook, PauseHookParams, PiecePropertyMap, StaticPropsValue, StopHook, StopHookParams, TagsManager } from '@activepieces/pieces-framework' @@ -113,11 +113,11 @@ const executeAction: ActionHandler = async ({ action, executionStat const runMethodToExecute = (constants.testSingleStepMode && !isNil(pieceAction.test)) ? pieceAction.test : pieceAction.run const output = await runMethodToExecute(context) const newExecutionContext = executionState.addTags(hookResponse.tags) - + if (hookResponse.stopped) { assertNotNullOrUndefined(hookResponse.stopResponse, 'stopResponse') return newExecutionContext.upsertStep(action.name, stepOutput.setOutput(output)).setVerdict(ExecutionVerdict.SUCCEEDED, { - reason: FlowExecutionStatus.STOPPED, + reason: FlowRunStatus.STOPPED, stopResponse: hookResponse.stopResponse.response, }).increaseTask() } @@ -125,7 +125,7 @@ const executeAction: ActionHandler = async ({ action, executionStat assertNotNullOrUndefined(hookResponse.pauseResponse, 'pauseResponse') return newExecutionContext.upsertStep(action.name, stepOutput.setOutput(output).setStatus(StepOutputStatus.PAUSED)) .setVerdict(ExecutionVerdict.PAUSED, { - reason: FlowExecutionStatus.PAUSED, + reason: FlowRunStatus.PAUSED, pauseMetadata: hookResponse.pauseResponse.pauseMetadata, }) } diff --git a/packages/engine/src/main.ts b/packages/engine/src/main.ts index 28c1667672..2ba43f45ee 100755 --- a/packages/engine/src/main.ts +++ b/packages/engine/src/main.ts @@ -19,7 +19,7 @@ import { Action, ActionType, isNil, - FlowExecutionResponse, + FlowRunResponse, } from '@activepieces/shared' import { pieceHelper } from './lib/helper/piece-helper' import { triggerHelper } from './lib/helper/trigger-helper' @@ -29,7 +29,7 @@ import { ExecutionVerdict, FlowExecutorContext } from './lib/handler/context/flo import { EngineConstants } from './lib/handler/context/engine-constants' import { testExecutionContext } from './lib/handler/context/test-execution-context' -const executeFlow = async (input: ExecuteFlowOperation, context: FlowExecutorContext): Promise> => { +const executeFlow = async (input: ExecuteFlowOperation, context: FlowExecutorContext): Promise> => { const output = await flowExecutor.execute({ action: input.flowVersion.trigger.nextAction, executionState: context, diff --git a/packages/engine/test/handler/flow-with-response.test.ts b/packages/engine/test/handler/flow-with-response.test.ts index 6b965041c6..d4708d91f2 100644 --- a/packages/engine/test/handler/flow-with-response.test.ts +++ b/packages/engine/test/handler/flow-with-response.test.ts @@ -1,6 +1,7 @@ import { ExecutionVerdict, FlowExecutorContext } from '../../src/lib/handler/context/flow-execution-context' import { buildPieceAction, generateMockEngineConstants } from './test-helper' import { flowExecutor } from '../../src/lib/handler/flow-executor' +import { FlowRunStatus } from '@activepieces/shared' describe('flow with response', () => { @@ -24,7 +25,7 @@ describe('flow with response', () => { }) expect(result.verdict).toBe(ExecutionVerdict.SUCCEEDED) expect(result.verdictResponse).toEqual({ - reason: 'STOPPED', + reason: FlowRunStatus.STOPPED, stopResponse: response, }) expect(result.steps.http.output).toEqual(response) diff --git a/packages/server/api/src/app/ee/flow-worker/cloud-flow-worker-hooks.ts b/packages/server/api/src/app/ee/flow-worker/cloud-flow-worker-hooks.ts index 30a5670c0c..0acc63a9e9 100644 --- a/packages/server/api/src/app/ee/flow-worker/cloud-flow-worker-hooks.ts +++ b/packages/server/api/src/app/ee/flow-worker/cloud-flow-worker-hooks.ts @@ -2,7 +2,7 @@ import { ActivepiecesError, ApEdition, ErrorCode, - FlowExecutionStatus, + FlowRunStatus, } from '@activepieces/shared' import { getEdition } from '../../helper/secret-helper' import { flowRunService } from '../../flows/flow-run/flow-run-service' @@ -32,7 +32,7 @@ export const platformWorkerHooks: FlowWorkerHooks = { ) { await flowRunService.finish({ flowRunId: runId, - status: FlowExecutionStatus.QUOTA_EXCEEDED, + status: FlowRunStatus.QUOTA_EXCEEDED, tasks: 0, logsFileId: null, tags: [], diff --git a/packages/server/api/src/app/flows/flow-run/flow-response-watcher.ts b/packages/server/api/src/app/flows/flow-run/flow-response-watcher.ts index 8d3c92e0a5..28fa45fa3b 100644 --- a/packages/server/api/src/app/flows/flow-run/flow-response-watcher.ts +++ b/packages/server/api/src/app/flows/flow-run/flow-response-watcher.ts @@ -1,7 +1,7 @@ import { logger } from '@sentry/utils' import { - FlowExecutionResponse, - FlowExecutionStatus, + FlowRunResponse, + FlowRunStatus, PauseType, apId, } from '@activepieces/shared' @@ -68,7 +68,7 @@ export const flowResponseWatcher = { async publish( flowRunId: string, handlerId: string, - result: FlowExecutionResponse, + result: FlowRunResponse, ): Promise { logger.info(`[flowRunWatcher#publish] flowRunId=${flowRunId}`) const flowResponse = await getFlowResponse(result) @@ -81,10 +81,10 @@ export const flowResponseWatcher = { } async function getFlowResponse( - result: FlowExecutionResponse, + result: FlowRunResponse, ): Promise { switch (result.status) { - case FlowExecutionStatus.PAUSED: + case FlowRunStatus.PAUSED: if (result.pauseMetadata && result.pauseMetadata.type === PauseType.WEBHOOK) { return { status: StatusCodes.OK, @@ -97,13 +97,13 @@ async function getFlowResponse( body: {}, headers: {}, } - case FlowExecutionStatus.STOPPED: + case FlowRunStatus.STOPPED: return { status: result.stopResponse?.status ?? StatusCodes.OK, body: result.stopResponse?.body, headers: result.stopResponse?.headers ?? {}, } - case FlowExecutionStatus.INTERNAL_ERROR: + case FlowRunStatus.INTERNAL_ERROR: return { status: StatusCodes.INTERNAL_SERVER_ERROR, body: { @@ -111,7 +111,7 @@ async function getFlowResponse( }, headers: {}, } - case FlowExecutionStatus.FAILED: + case FlowRunStatus.FAILED: return { status: StatusCodes.INTERNAL_SERVER_ERROR, body: { @@ -119,8 +119,8 @@ async function getFlowResponse( }, headers: {}, } - case FlowExecutionStatus.TIMEOUT: - case FlowExecutionStatus.RUNNING: + case FlowRunStatus.TIMEOUT: + case FlowRunStatus.RUNNING: return { status: StatusCodes.GATEWAY_TIMEOUT, body: { @@ -128,8 +128,8 @@ async function getFlowResponse( }, headers: {}, } - case FlowExecutionStatus.SUCCEEDED: - case FlowExecutionStatus.QUOTA_EXCEEDED: + case FlowRunStatus.SUCCEEDED: + case FlowRunStatus.QUOTA_EXCEEDED: return { status: StatusCodes.NO_CONTENT, body: {}, diff --git a/packages/server/api/src/app/flows/flow-run/flow-run-service.ts b/packages/server/api/src/app/flows/flow-run/flow-run-service.ts index a6a264a4fb..5c89aef97b 100644 --- a/packages/server/api/src/app/flows/flow-run/flow-run-service.ts +++ b/packages/server/api/src/app/flows/flow-run/flow-run-service.ts @@ -19,7 +19,7 @@ import { FlowRetryStrategy, PauseType, ResumePayload, - FlowExecutionStatus, + FlowRunStatus, ExecutioOutputFile, } from '@activepieces/shared' import { @@ -186,7 +186,7 @@ export const flowRunService = { tags, }: { flowRunId: FlowRunId - status: FlowExecutionStatus + status: FlowRunStatus tasks: number tags: string[] logsFileId: FileId | null @@ -240,7 +240,7 @@ export const flowRunService = { flowDisplayName: flowVersion.displayName, }) - flowRun.status = FlowExecutionStatus.RUNNING + flowRun.status = FlowRunStatus.RUNNING const savedFlowRun = await flowRunRepo.save(flowRun) @@ -293,7 +293,7 @@ export const flowRunService = { const { flowRunId, logFileId, pauseMetadata } = params await flowRunRepo.update(flowRunId, { - status: FlowExecutionStatus.PAUSED, + status: FlowRunStatus.PAUSED, logsFileId: logFileId, // eslint-disable-next-line @typescript-eslint/no-explicit-any pauseMetadata: pauseMetadata as any, @@ -360,7 +360,7 @@ type GetOrCreateParams = { type ListParams = { projectId: ProjectId flowId: FlowId | undefined - status: FlowExecutionStatus | undefined + status: FlowRunStatus | undefined cursor: Cursor | null tags?: string[] limit: number diff --git a/packages/server/api/src/app/helper/engine-helper.ts b/packages/server/api/src/app/helper/engine-helper.ts index 970504a50c..30faec4f5f 100644 --- a/packages/server/api/src/app/helper/engine-helper.ts +++ b/packages/server/api/src/app/helper/engine-helper.ts @@ -28,7 +28,7 @@ import { FlowVersion, ExecuteFlowOperation, PlatformRole, - FlowExecutionResponse, + FlowRunResponse, } from '@activepieces/shared' import { Sandbox } from 'server-worker' import { accessTokenManager } from '../authentication/lib/access-token-manager' @@ -55,7 +55,7 @@ type GenerateWorkerTokenParams = { projectId: ProjectId } -export type EngineHelperFlowResult = FlowExecutionResponse +export type EngineHelperFlowResult = FlowRunResponse export type EngineHelperTriggerResult< T extends TriggerHookType = TriggerHookType, diff --git a/packages/server/api/src/app/helper/notifications.ts b/packages/server/api/src/app/helper/notifications.ts index 4410d21d51..ee9e7d266c 100644 --- a/packages/server/api/src/app/helper/notifications.ts +++ b/packages/server/api/src/app/helper/notifications.ts @@ -1,5 +1,5 @@ import { - FlowExecutionStatus, + FlowRunStatus, FlowRun, NotificationStatus, RunEnvironment, @@ -19,8 +19,8 @@ export const notifications = { } if ( ![ - FlowExecutionStatus.FAILED, - FlowExecutionStatus.INTERNAL_ERROR, + FlowRunStatus.FAILED, + FlowRunStatus.INTERNAL_ERROR, ].includes(flowRun.status) ) { return diff --git a/packages/server/api/src/app/workers/flow-worker/flow-worker.ts b/packages/server/api/src/app/workers/flow-worker/flow-worker.ts index 70ae78b6c6..01c388f5bb 100644 --- a/packages/server/api/src/app/workers/flow-worker/flow-worker.ts +++ b/packages/server/api/src/app/workers/flow-worker/flow-worker.ts @@ -12,8 +12,7 @@ import { FileCompression, FileId, FileType, - FlowExecutionResponse, - FlowExecutionStatus, + FlowRunStatus, flowHelper, FlowRunId, FlowVersion, @@ -25,6 +24,7 @@ import { SourceCode, Trigger, TriggerType, + FlowRunResponse, } from '@activepieces/shared' import { Sandbox } from 'server-worker' import { flowVersionService } from '../../flows/flow-version/flow-version.service' @@ -48,7 +48,7 @@ import { logSerializer } from 'server-worker' type FinishExecutionParams = { flowRunId: FlowRunId logFileId: FileId - result: FlowExecutionResponse + result: FlowRunResponse } type LoadInputAndLogFileIdParams = { @@ -94,7 +94,7 @@ const finishExecution = async ( const { flowRunId, logFileId, result } = params - if (result.status === FlowExecutionStatus.PAUSED) { + if (result.status === FlowRunStatus.PAUSED) { await flowRunService.pause({ flowRunId, logFileId, @@ -113,10 +113,10 @@ const finishExecution = async ( } const getTerminalStatus = ( - status: FlowExecutionStatus, -): FlowExecutionStatus => { - return status == FlowExecutionStatus.STOPPED - ? FlowExecutionStatus.SUCCEEDED + status: FlowRunStatus, +): FlowRunStatus => { + return status == FlowRunStatus.STOPPED + ? FlowRunStatus.SUCCEEDED : status } @@ -160,7 +160,7 @@ const loadInputAndLogFileId = async ({ } case ExecutionType.BEGIN: if (!isNil(flowRun.logsFileId)) { - if (flowRun.status !== FlowExecutionStatus.INTERNAL_ERROR) { + if (flowRun.status !== FlowRunStatus.INTERNAL_ERROR) { const trigger = Object.values(flowRun.steps).find((step) => flowHelper.isTrigger(step.type)) assertNotNullOrUndefined( trigger, @@ -280,7 +280,7 @@ async function executeFlow(jobData: OneTimeJobData): Promise { ) { await flowRunService.finish({ flowRunId: jobData.runId, - status: FlowExecutionStatus.QUOTA_EXCEEDED, + status: FlowRunStatus.QUOTA_EXCEEDED, tasks: 0, logsFileId: null, tags: [], @@ -292,7 +292,7 @@ async function executeFlow(jobData: OneTimeJobData): Promise { ) { await flowRunService.finish({ flowRunId: jobData.runId, - status: FlowExecutionStatus.TIMEOUT, + status: FlowRunStatus.TIMEOUT, // TODO REVIST THIS tasks: 10, logsFileId: null, @@ -302,7 +302,7 @@ async function executeFlow(jobData: OneTimeJobData): Promise { else { await flowRunService.finish({ flowRunId: jobData.runId, - status: FlowExecutionStatus.INTERNAL_ERROR, + status: FlowRunStatus.INTERNAL_ERROR, tasks: 0, logsFileId: null, tags: [], diff --git a/packages/server/api/src/app/workers/flow-worker/queues/memory/memory-queue.ts b/packages/server/api/src/app/workers/flow-worker/queues/memory/memory-queue.ts index 1c9722f0f8..1546cff804 100644 --- a/packages/server/api/src/app/workers/flow-worker/queues/memory/memory-queue.ts +++ b/packages/server/api/src/app/workers/flow-worker/queues/memory/memory-queue.ts @@ -14,7 +14,7 @@ import { logger } from 'server-shared' import { DelayPauseMetadata, Flow, - FlowExecutionStatus, + FlowRunStatus, PauseType, RunEnvironment, TriggerType, @@ -164,7 +164,7 @@ export const inMemoryQueueManager: InMemoryQueueManager = { }) const flowRuns = await flowRunRepo.findBy({ - status: FlowExecutionStatus.PAUSED, + status: FlowRunStatus.PAUSED, }) logger.info(`Adding ${flowRuns.length} flow runs to the queue manager.`) flowRuns.forEach((flowRun) => { diff --git a/packages/server/api/test/helpers/mocks/index.ts b/packages/server/api/test/helpers/mocks/index.ts index 48cd6b9442..57fa6b7d9e 100644 --- a/packages/server/api/test/helpers/mocks/index.ts +++ b/packages/server/api/test/helpers/mocks/index.ts @@ -32,7 +32,7 @@ import { FlowTemplate, TemplateType, FlowRun, - FlowExecutionStatus, + FlowRunStatus, RunEnvironment, Platform, FilteredPieceBehavior, @@ -110,7 +110,7 @@ export const createMockProject = (project?: Partial): Project => { ownerId: project?.ownerId ?? apId(), displayName: project?.displayName ?? faker.lorem.word(), notifyStatus: - project?.notifyStatus ?? faker.helpers.enumValue(NotificationStatus), + project?.notifyStatus ?? faker.helpers.enumValue(NotificationStatus), platformId: project?.platformId ?? apId(), externalId: project?.externalId ?? apId(), } @@ -148,8 +148,8 @@ export const createMockPlatform = (platform?: Partial): Platform => { filteredPieceNames: platform?.filteredPieceNames ?? [], ssoEnabled: platform?.ssoEnabled ?? faker.datatype.boolean(), filteredPieceBehavior: - platform?.filteredPieceBehavior ?? - faker.helpers.enumValue(FilteredPieceBehavior), + platform?.filteredPieceBehavior ?? + faker.helpers.enumValue(FilteredPieceBehavior), smtpHost: platform?.smtpHost ?? faker.internet.domainName(), smtpPort: platform?.smtpPort ?? faker.internet.port(), smtpUser: platform?.smtpUser ?? faker.internet.userName(), @@ -202,7 +202,7 @@ export const createMockProjectMember = ( projectId: projectMember?.projectId ?? apId(), role: projectMember?.role ?? faker.helpers.enumValue(ProjectMemberRole), status: - projectMember?.status ?? faker.helpers.enumValue(ProjectMemberStatus), + projectMember?.status ?? faker.helpers.enumValue(ProjectMemberStatus), } } @@ -281,7 +281,7 @@ export const createProjectMember = ( projectId: projectMember.projectId ?? apId(), role: projectMember.role ?? faker.helpers.enumValue(ProjectMember.Role), status: - projectMember.status ?? faker.helpers.enumValue(ProjectMember.Status), + projectMember.status ?? faker.helpers.enumValue(ProjectMember.Status), created: projectMember.created ?? faker.date.recent().toISOString(), updated: projectMember.updated ?? faker.date.recent().toISOString(), } @@ -309,7 +309,7 @@ export const createMockPieceMetadata = ( triggers: pieceMetadata?.triggers ?? {}, pieceType: pieceMetadata?.pieceType ?? faker.helpers.enumValue(PieceType), packageType: - pieceMetadata?.packageType ?? faker.helpers.enumValue(PackageType), + pieceMetadata?.packageType ?? faker.helpers.enumValue(PackageType), archiveId: pieceMetadata?.archiveId, } } @@ -350,14 +350,14 @@ export const createMockOtp = (otp?: Partial): OtpModel => { id: otp?.id ?? apId(), created: otp?.created ?? faker.date.recent().toISOString(), updated: - otp?.updated ?? - faker.date - .between({ from: twentyMinutesAgo.toDate(), to: now.toDate() }) - .toISOString(), + otp?.updated ?? + faker.date + .between({ from: twentyMinutesAgo.toDate(), to: now.toDate() }) + .toISOString(), type: otp?.type ?? faker.helpers.enumValue(OtpType), userId: otp?.userId ?? apId(), value: - otp?.value ?? faker.number.int({ min: 100000, max: 999999 }).toString(), + otp?.value ?? faker.number.int({ min: 100000, max: 999999 }).toString(), state: otp?.state ?? faker.helpers.enumValue(OtpState), } } @@ -370,15 +370,16 @@ export const createMockFlowRun = (flowRun?: Partial): FlowRun => { projectId: flowRun?.projectId ?? apId(), flowId: flowRun?.flowId ?? apId(), tags: flowRun?.tags ?? [], + steps: {}, flowVersionId: flowRun?.flowVersionId ?? apId(), flowDisplayName: flowRun?.flowDisplayName ?? faker.lorem.word(), logsFileId: flowRun?.logsFileId ?? null, tasks: flowRun?.tasks, - status: flowRun?.status ?? faker.helpers.enumValue(FlowExecutionStatus), + status: flowRun?.status ?? faker.helpers.enumValue(FlowRunStatus), startTime: flowRun?.startTime ?? faker.date.recent().toISOString(), finishTime: flowRun?.finishTime ?? faker.date.recent().toISOString(), environment: - flowRun?.environment ?? faker.helpers.enumValue(RunEnvironment), + flowRun?.environment ?? faker.helpers.enumValue(RunEnvironment), } } diff --git a/packages/server/api/test/integration/ce/flows/flow-worker.test.ts b/packages/server/api/test/integration/ce/flows/flow-worker.test.ts index c4a3d51cdb..f4eb461fd4 100644 --- a/packages/server/api/test/integration/ce/flows/flow-worker.test.ts +++ b/packages/server/api/test/integration/ce/flows/flow-worker.test.ts @@ -1,6 +1,6 @@ import { ActionType, - FlowExecutionStatus, + FlowRunStatus, ExecutionType, FlowStatus, FlowVersionState, @@ -111,7 +111,7 @@ describe('flow execution', () => { flowVersionId: mockFlowVersion.id, projectId: mockProject.id, flowId: mockFlow.id, - status: FlowExecutionStatus.RUNNING, + status: FlowRunStatus.RUNNING, }) await databaseConnection.getRepository('flow_run').save([mockFlowRun]) @@ -129,7 +129,7 @@ describe('flow execution', () => { .findOneByOrFail({ id: mockFlowRun.id, }) - expect(flowRun.status).toEqual(FlowExecutionStatus.SUCCEEDED) + expect(flowRun.status).toEqual(FlowRunStatus.SUCCEEDED) const file = await databaseConnection .getRepository('file') diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 24f70bcb8c..ac3aad7735 100755 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -53,7 +53,7 @@ export { FileResponseInterface } from './lib/forms' export * from './lib/platform' import { TypeSystem } from '@sinclair/typebox/system' export { StopResponse } from './lib/flow-run/execution/flow-execution' -export { PauseType, FlowExecutionStatus, FlowExecutionResponse } from './lib/flow-run/execution/flow-execution' +export { PauseType, FlowRunStatus, FlowRunResponse } from './lib/flow-run/execution/flow-execution' export { DelayPauseMetadata, PauseMetadata, WebhookPauseMetadata } from './lib/flow-run/execution/flow-execution' export * from './lib/federated-authn' export { STORE_KEY_MAX_LENGTH } from './lib/store-entry/store-entry' diff --git a/packages/shared/src/lib/flow-run/dto/list-flow-runs-request.ts b/packages/shared/src/lib/flow-run/dto/list-flow-runs-request.ts index ce13b85a29..4c4c86172c 100755 --- a/packages/shared/src/lib/flow-run/dto/list-flow-runs-request.ts +++ b/packages/shared/src/lib/flow-run/dto/list-flow-runs-request.ts @@ -1,12 +1,12 @@ import { ApId } from '../../common/id-generator' import { Cursor } from '../../common/seek-page' import { Static, Type } from '@sinclair/typebox' -import { FlowExecutionStatus } from '../execution/flow-execution' +import { FlowRunStatus } from '../execution/flow-execution' export const ListFlowRunsRequestQuery = Type.Object({ flowId: Type.Optional(ApId), tags: Type.Optional(Type.Array(Type.String({}))), - status: Type.Optional(Type.Enum(FlowExecutionStatus)), + status: Type.Optional(Type.Enum(FlowRunStatus)), limit: Type.Optional(Type.Number({})), cursor: Type.Optional(Type.String({})), createdAfter: Type.Optional(Type.String({})), diff --git a/packages/shared/src/lib/flow-run/execution/flow-execution.ts b/packages/shared/src/lib/flow-run/execution/flow-execution.ts index 1977da7a4d..b448dbd7bf 100644 --- a/packages/shared/src/lib/flow-run/execution/flow-execution.ts +++ b/packages/shared/src/lib/flow-run/execution/flow-execution.ts @@ -2,7 +2,7 @@ import { Static, Type } from '@sinclair/typebox' import { ExecutionState } from './execution-output' -export enum FlowExecutionStatus { +export enum FlowRunStatus { FAILED = 'FAILED', QUOTA_EXCEEDED = 'QUOTA_EXCEEDED', INTERNAL_ERROR = 'INTERNAL_ERROR', @@ -55,22 +55,22 @@ const BaseExecutiionResponse = { stopResponse: Type.Optional(StopResponse), } -export const FlowExecutionResponse = Type.Union([ +export const FlowRunResponse = Type.Union([ Type.Object({ - status: Type.Literal(FlowExecutionStatus.PAUSED), + status: Type.Literal(FlowRunStatus.PAUSED), ...BaseExecutiionResponse, pauseMetadata: Type.Optional(PauseMetadata), }), Type.Object({ - status: Type.Union([Type.Literal(FlowExecutionStatus.FAILED), - Type.Literal(FlowExecutionStatus.SUCCEEDED), - Type.Literal(FlowExecutionStatus.RUNNING), - Type.Literal(FlowExecutionStatus.QUOTA_EXCEEDED), - Type.Literal(FlowExecutionStatus.TIMEOUT), - Type.Literal(FlowExecutionStatus.INTERNAL_ERROR), - Type.Literal(FlowExecutionStatus.STOPPED), + status: Type.Union([Type.Literal(FlowRunStatus.FAILED), + Type.Literal(FlowRunStatus.SUCCEEDED), + Type.Literal(FlowRunStatus.RUNNING), + Type.Literal(FlowRunStatus.QUOTA_EXCEEDED), + Type.Literal(FlowRunStatus.TIMEOUT), + Type.Literal(FlowRunStatus.INTERNAL_ERROR), + Type.Literal(FlowRunStatus.STOPPED), ]), ...BaseExecutiionResponse, }), ]) -export type FlowExecutionResponse = Static & ExecutionState +export type FlowRunResponse = Static & ExecutionState diff --git a/packages/shared/src/lib/flow-run/flow-run.ts b/packages/shared/src/lib/flow-run/flow-run.ts index c46896f996..e2c6f2a56e 100755 --- a/packages/shared/src/lib/flow-run/flow-run.ts +++ b/packages/shared/src/lib/flow-run/flow-run.ts @@ -1,5 +1,5 @@ import { ApId } from '../common/id-generator' -import { FlowExecutionStatus, PauseMetadata } from './execution/flow-execution' +import { FlowRunStatus, PauseMetadata } from './execution/flow-execution' import { Static, Type } from '@sinclair/typebox' import { BaseModelSchema, Nullable } from '../common/base-model' import { ExecutionState } from './execution/execution-output' @@ -31,7 +31,7 @@ export const FlowRun = Type.Object({ terminationReason: Type.Optional(Type.String()), logsFileId: Nullable(Type.String()), tasks: Type.Optional(Type.Number()), - status: Type.Enum(FlowExecutionStatus), + status: Type.Enum(FlowRunStatus), startTime: Type.String(), finishTime: Type.String(), environment: Type.Enum(RunEnvironment), diff --git a/packages/ui/common/src/lib/components/status-icon/state-icon.component.ts b/packages/ui/common/src/lib/components/status-icon/state-icon.component.ts index bf3ca18684..aabb857b6a 100644 --- a/packages/ui/common/src/lib/components/status-icon/state-icon.component.ts +++ b/packages/ui/common/src/lib/components/status-icon/state-icon.component.ts @@ -7,7 +7,7 @@ import { } from '@angular/core'; import { AppConnectionStatus, - FlowExecutionStatus, + FlowRunStatus, StepOutputStatus, } from '@activepieces/shared'; @@ -18,9 +18,9 @@ import { export class StateIconComponent implements OnInit, OnChanges { @Input() size = 16; @Input() showStatusText = true; - @Input() status: FlowExecutionStatus | StepOutputStatus | AppConnectionStatus; + @Input() status: FlowRunStatus | StepOutputStatus | AppConnectionStatus; textAfter = ''; - readonly ExecutionOutputStatus = FlowExecutionStatus; + readonly ExecutionOutputStatus = FlowRunStatus; readonly StepOutputStatus = StepOutputStatus; iconUrl = ''; @@ -33,52 +33,52 @@ export class StateIconComponent implements OnInit, OnChanges { this.iconUrl = this.findIconUrl(this.status); } findIconUrl( - status: FlowExecutionStatus | StepOutputStatus | AppConnectionStatus + status: FlowRunStatus | StepOutputStatus | AppConnectionStatus ): string { switch (status) { - case FlowExecutionStatus.STOPPED: - case FlowExecutionStatus.SUCCEEDED: + case FlowRunStatus.STOPPED: + case FlowRunStatus.SUCCEEDED: case StepOutputStatus.SUCCEEDED: case StepOutputStatus.STOPPED: case AppConnectionStatus.ACTIVE: return 'assets/img/custom/status/success.svg'; - case FlowExecutionStatus.FAILED: - case FlowExecutionStatus.INTERNAL_ERROR: - case FlowExecutionStatus.TIMEOUT: + case FlowRunStatus.FAILED: + case FlowRunStatus.INTERNAL_ERROR: + case FlowRunStatus.TIMEOUT: case StepOutputStatus.FAILED: case AppConnectionStatus.ERROR: - case FlowExecutionStatus.QUOTA_EXCEEDED: + case FlowRunStatus.QUOTA_EXCEEDED: return 'assets/img/custom/status/error.svg'; - case FlowExecutionStatus.PAUSED: + case FlowRunStatus.PAUSED: case StepOutputStatus.PAUSED: return 'assets/img/custom/status/paused.svg'; case StepOutputStatus.RUNNING: - case FlowExecutionStatus.RUNNING: + case FlowRunStatus.RUNNING: return ''; } } findTextAfter( - status: FlowExecutionStatus | StepOutputStatus | AppConnectionStatus + status: FlowRunStatus | StepOutputStatus | AppConnectionStatus ): string { switch (status) { - case FlowExecutionStatus.STOPPED: - case FlowExecutionStatus.SUCCEEDED: + case FlowRunStatus.STOPPED: + case FlowRunStatus.SUCCEEDED: case StepOutputStatus.SUCCEEDED: case StepOutputStatus.STOPPED: return $localize`Succeeded`; - case FlowExecutionStatus.QUOTA_EXCEEDED: + case FlowRunStatus.QUOTA_EXCEEDED: return 'Quota Exceeded'; - case FlowExecutionStatus.INTERNAL_ERROR: + case FlowRunStatus.INTERNAL_ERROR: return $localize`Internal Error`; - case FlowExecutionStatus.TIMEOUT: + case FlowRunStatus.TIMEOUT: return $localize`Timed Out`; - case FlowExecutionStatus.FAILED: + case FlowRunStatus.FAILED: case StepOutputStatus.FAILED: return $localize`Failed`; - case FlowExecutionStatus.PAUSED: + case FlowRunStatus.PAUSED: case StepOutputStatus.PAUSED: return $localize`Paused`; - case FlowExecutionStatus.RUNNING: + case FlowRunStatus.RUNNING: case StepOutputStatus.RUNNING: return $localize`Running`; case AppConnectionStatus.ACTIVE: diff --git a/packages/ui/common/src/lib/models/flow-run.interface.ts b/packages/ui/common/src/lib/models/flow-run.interface.ts index 1296577fbc..e765a256b1 100755 --- a/packages/ui/common/src/lib/models/flow-run.interface.ts +++ b/packages/ui/common/src/lib/models/flow-run.interface.ts @@ -1,8 +1,4 @@ -import { - FlowExecutionStatus, - FlowRun, - RunEnvironment, -} from '@activepieces/shared'; +import { FlowRunStatus, FlowRun, RunEnvironment } from '@activepieces/shared'; export const initializedRun: FlowRun = { id: '', @@ -11,7 +7,7 @@ export const initializedRun: FlowRun = { flowId: '', tags: [], steps: {}, - status: FlowExecutionStatus.RUNNING, + status: FlowRunStatus.RUNNING, logsFileId: '', startTime: '', finishTime: '', diff --git a/packages/ui/feature-builder-canvas/src/lib/components/flow-item-tree/flow-item/flow-item-content/flow-item-content.component.ts b/packages/ui/feature-builder-canvas/src/lib/components/flow-item-tree/flow-item/flow-item-content/flow-item-content.component.ts index f60017c276..b2363439ec 100755 --- a/packages/ui/feature-builder-canvas/src/lib/components/flow-item-tree/flow-item/flow-item-content/flow-item-content.component.ts +++ b/packages/ui/feature-builder-canvas/src/lib/components/flow-item-tree/flow-item/flow-item-content/flow-item-content.component.ts @@ -24,7 +24,7 @@ import { RunDetailsService } from '@activepieces/ui/feature-builder-left-sidebar import { Action, ActionType, - FlowExecutionStatus, + FlowRunStatus, FlowRun, StepOutput, StepOutputStatus, @@ -81,7 +81,7 @@ export class FlowItemContentComponent implements OnInit { isOverflown = isOverflown; childStepsIconsUrls: Record> = {}; StepOutputStatus = StepOutputStatus; - ExecutionOutputStatus = FlowExecutionStatus; + ExecutionOutputStatus = FlowRunStatus; TriggerType = TriggerType; ActionType = ActionType; stepIndex$: Observable; @@ -164,7 +164,7 @@ export class FlowItemContentComponent implements OnInit { distinctUntilChanged(), map((selectedRun) => { if (selectedRun) { - if (selectedRun.status !== FlowExecutionStatus.RUNNING) { + if (selectedRun.status !== FlowRunStatus.RUNNING) { const stepName = this._flowItem.name; const result = selectedRun.steps[stepName.toString()]; if (result) { diff --git a/packages/ui/feature-builder-canvas/src/lib/components/widgets/test-flow-widget/test-flow-widget.component.ts b/packages/ui/feature-builder-canvas/src/lib/components/widgets/test-flow-widget/test-flow-widget.component.ts index 41e1c776ae..18bcf5eb0a 100644 --- a/packages/ui/feature-builder-canvas/src/lib/components/widgets/test-flow-widget/test-flow-widget.component.ts +++ b/packages/ui/feature-builder-canvas/src/lib/components/widgets/test-flow-widget/test-flow-widget.component.ts @@ -9,7 +9,7 @@ import { import { Store } from '@ngrx/store'; import { MatSnackBar, MatSnackBarRef } from '@angular/material/snack-bar'; import { - FlowExecutionStatus, + FlowRunStatus, FlowRun, PopulatedFlow, TriggerType, @@ -30,8 +30,8 @@ import { canvasActions } from '@activepieces/ui/feature-builder-store'; }) export class TestFlowWidgetComponent implements OnInit { triggerType = TriggerType; - statusEnum = FlowExecutionStatus; - instanceRunStatus$: Observable; + statusEnum = FlowRunStatus; + instanceRunStatus$: Observable; isSaving$: Observable = of(false); selectedFlow$: Observable; instanceRunStatusChecker$: Observable; diff --git a/packages/ui/feature-builder-left-sidebar/src/lib/components/run-details/run-details.component.ts b/packages/ui/feature-builder-left-sidebar/src/lib/components/run-details/run-details.component.ts index 868c82d080..33335b8e75 100644 --- a/packages/ui/feature-builder-left-sidebar/src/lib/components/run-details/run-details.component.ts +++ b/packages/ui/feature-builder-left-sidebar/src/lib/components/run-details/run-details.component.ts @@ -13,7 +13,7 @@ import { Store } from '@ngrx/store'; import { RunDetailsService } from './iteration-details.service'; import { CdkDragMove } from '@angular/cdk/drag-drop'; import { - FlowExecutionStatus, + FlowRunStatus, FlowRun, StepOutput, StepOutputStatus, @@ -115,7 +115,7 @@ export class RunDetailsComponent implements OnInit { } public get InstanceRunStatus() { - return FlowExecutionStatus; + return FlowRunStatus; } resizerDragStarted(stepsResultsAccordion: HTMLElement) { diff --git a/packages/ui/feature-builder-store/src/lib/store/builder/builder.selector.ts b/packages/ui/feature-builder-store/src/lib/store/builder/builder.selector.ts index e0245f7844..88d31306df 100755 --- a/packages/ui/feature-builder-store/src/lib/store/builder/builder.selector.ts +++ b/packages/ui/feature-builder-store/src/lib/store/builder/builder.selector.ts @@ -2,7 +2,7 @@ import { createFeatureSelector, createSelector } from '@ngrx/store'; import { GlobalBuilderState } from '../../model/global-builder-state.model'; import { - FlowExecutionStatus, + FlowRunStatus, FlowRun, FlowVersion, FlowVersionState, @@ -259,7 +259,7 @@ const selectStepResultsAccordion = createSelector( selectCurrentFlow, selectCurrentFlowRun, (flow, run) => { - if (!run || run.status === FlowExecutionStatus.RUNNING) { + if (!run || run.status === FlowRunStatus.RUNNING) { return []; } const steps = flowHelper.getAllSteps(flow.version.trigger); diff --git a/packages/ui/feature-builder-store/src/lib/test-run-bar/test-run-bar.component.ts b/packages/ui/feature-builder-store/src/lib/test-run-bar/test-run-bar.component.ts index e254120423..dd57eaee6c 100755 --- a/packages/ui/feature-builder-store/src/lib/test-run-bar/test-run-bar.component.ts +++ b/packages/ui/feature-builder-store/src/lib/test-run-bar/test-run-bar.component.ts @@ -5,7 +5,7 @@ import { MatSnackBarRef, MAT_SNACK_BAR_DATA, } from '@angular/material/snack-bar'; -import { FlowExecutionStatus, FlowId, FlowRun } from '@activepieces/shared'; +import { FlowRunStatus, FlowId, FlowRun } from '@activepieces/shared'; import { BuilderSelectors } from '../store/builder/builder.selector'; import { FlagService } from '@activepieces/ui/common'; import { canvasActions } from '../store/builder/canvas/canvas.action'; @@ -59,6 +59,6 @@ export class TestRunBarComponent implements OnInit { } get instanceRunStatus() { - return FlowExecutionStatus; + return FlowRunStatus; } } diff --git a/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.component.ts b/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.component.ts index d65ceba70e..71cd45b5e7 100755 --- a/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.component.ts +++ b/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.component.ts @@ -6,7 +6,7 @@ import { } from '@angular/core'; import { ApEdition, - FlowExecutionStatus, + FlowRunStatus, FlowId, FlowRetryStrategy, FlowRun, @@ -65,9 +65,8 @@ export class RunsTableComponent implements OnInit { displayedColumns = ['flowName', 'status', 'started', 'finished', 'action']; updateNotificationsValue$: Observable; refreshTableForReruns$: Subject = new Subject(); - statusFilterControl: FormControl< - FlowExecutionStatus | typeof allOptionValue - > = new FormControl(allOptionValue, { nonNullable: true }); + statusFilterControl: FormControl = + new FormControl(allOptionValue, { nonNullable: true }); flowFilterControl = new FormControl(allOptionValue, { nonNullable: true, }); @@ -79,7 +78,7 @@ export class RunsTableComponent implements OnInit { flows$: Observable[]>; currentProject: ProjectId; filtersChanged$: Observable; - readonly ExecutionOutputStatus = FlowExecutionStatus; + readonly ExecutionOutputStatus = FlowRunStatus; FlowRetryStrategy: typeof FlowRetryStrategy = FlowRetryStrategy; retryFlow$?: Observable; setInitialFilters$?: Observable; @@ -101,7 +100,7 @@ export class RunsTableComponent implements OnInit { this.statusFilterControl.setValue( (this.activatedRoute.snapshot.queryParamMap.get( STATUS_QUERY_PARAM - ) as FlowExecutionStatus) || this.allOptionValue + ) as FlowRunStatus) || this.allOptionValue ); const startDate = this.activatedRoute.snapshot.queryParamMap.get( DATE_RANGE_START_QUERY_PARAM diff --git a/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.datasource.ts b/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.datasource.ts index 1239ad3515..de7f58900f 100755 --- a/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.datasource.ts +++ b/packages/ui/feature-dashboard/src/lib/pages/runs-table/runs-table.datasource.ts @@ -10,7 +10,7 @@ import { take, BehaviorSubject, } from 'rxjs'; -import { FlowExecutionStatus, FlowRun } from '@activepieces/shared'; +import { FlowRunStatus, FlowRun } from '@activepieces/shared'; import { InstanceRunService, ApPaginatorComponent, @@ -90,9 +90,7 @@ export class RunsTableDataSource extends DataSource { if (this.refreshTimer) { clearTimeout(this.refreshTimer); } - if ( - res.data.find((run) => run.status === FlowExecutionStatus.RUNNING) - ) { + if (res.data.find((run) => run.status === FlowRunStatus.RUNNING)) { this.refreshTimer = setTimeout(() => { this.refreshForExecutingRuns$.next(true); }, REFRESH_TABLE_DELAY); diff --git a/packages/ui/feature-flow-builder/src/lib/page/flow-builder/flow-builder.component.ts b/packages/ui/feature-flow-builder/src/lib/page/flow-builder/flow-builder.component.ts index 4f4244459a..ea41ea28ea 100644 --- a/packages/ui/feature-flow-builder/src/lib/page/flow-builder/flow-builder.component.ts +++ b/packages/ui/feature-flow-builder/src/lib/page/flow-builder/flow-builder.component.ts @@ -28,7 +28,7 @@ import { CdkDragMove } from '@angular/cdk/drag-drop'; import { MatSnackBar } from '@angular/material/snack-bar'; import { RunDetailsService } from '@activepieces/ui/feature-builder-left-sidebar'; import { - FlowExecutionStatus, + FlowRunStatus, FlowVersion, TriggerType, } from '@activepieces/shared'; @@ -155,7 +155,7 @@ export class FlowBuilderComponent implements OnInit, OnDestroy { } public get instanceRunStatus() { - return FlowExecutionStatus; + return FlowRunStatus; } public get leftSideBarType() {