Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
activepieces:
image: ghcr.io/activepieces/activepieces:0.77.1
image: ghcr.io/activepieces/activepieces:0.77.2
container_name: activepieces
restart: unless-stopped
## Enable the following line if you already use AP_EXECUTION_MODE with SANDBOX_PROCESS or old activepieces, checking the breaking change documentation for more info.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "activepieces",
"version": "0.77.1",
"version": "0.77.2",
"rcVersion": "0.78.0-rc.0",
"scripts": {
"prepare": "husky install",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { AgentTimeline } from '@/features/agents/agent-timeline';
import { StepStatusIcon } from '@/features/flow-runs/components/step-status-icon';
import { flowRunUtils } from '@/features/flow-runs/lib/flow-run-utils';
import { flagsHooks } from '@/hooks/flags-hooks';
import { formatUtils } from '@/lib/utils';
import {
StepOutputStatus,
flowStructureUtil,
AgentResult,
isFlowRunStateTerminal,
FlowRun,
FlowRunStatus,
isNil,
ApFlagId,
} from '@activepieces/shared';

import { useBuilderStateContext } from '../builder-hooks';
Expand Down Expand Up @@ -62,10 +67,27 @@ export const FlowStepInputOutput = () => {
status: run.status,
ignoreInternalError: true,
});
const { data: rententionDays } = flagsHooks.useFlag<number>(
ApFlagId.EXECUTION_DATA_RETENTION_DAYS,
);

const message = handleRunFailureOrEmptyLog(run, rententionDays);
if (message) {
return (
<div className="flex flex-col justify-center items-center gap-4 w-full pt-8 px-5">
<Info size={36} className="text-muted-foreground" />
<h4 className="px-6 text-sm text-center text-muted-foreground ">
{message}
</h4>
</div>
);
}

if (!isRunDone) {
return <OutputSkeleton />;
}

if (!selectedStepOutput || !selectedStep) {
if (!isRunDone) {
return <OutputSkeleton />;
}
return (
<div className="px-4 bg-muted rounded-md m-4 py-2 flex items-center gap-1.5">
<Info className="w-4 h-4" />
Expand Down Expand Up @@ -137,3 +159,25 @@ const OutputSkeleton = () => {
</div>
);
};

function handleRunFailureOrEmptyLog(
run: FlowRun | null,
retentionDays: number | null,
) {
if (isNil(run)) {
return null;
}
if ([FlowRunStatus.INTERNAL_ERROR].includes(run.status)) {
return t(
'There are no logs captured for this run, because of an internal error, please contact support.',
);
}

if (isNil(run.logsFileId)) {
return t(
'Logs are kept for {days} days after execution and then deleted.',
{ days: retentionDays },
);
}
return null;
}
5 changes: 4 additions & 1 deletion packages/react-ui/src/app/builder/step-settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,10 @@ const StepSettingsContainer = () => {
onResize={(size) => setHeight(size)}
className="min-h-[130px]"
>
<ScrollArea className="h-[calc(100%-35px)] ">
<ScrollArea
className="h-[calc(100%-35px)]"
viewPortClassName="h-full"
>
{showGenerateSampleData && (
<TestStepContainer
type={modifiedStep.type}
Expand Down
1 change: 1 addition & 0 deletions packages/react-ui/src/app/routes/templates/id/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const TemplateDetailsPage = ({ template }: TemplateDetailsPageProps) => {
updatedBy: null,
agentIds: [],
connectionIds: [],
notes: selectedFlow.notes ?? [],
},
};
}, [template, selectedFlowIndex]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const oauthAppController: FastifyPluginAsyncTypebox = async (app) => {
'/',
{
config: {
security: securityAccess.platformAdminOnly([PrincipalType.USER]),
security: securityAccess.publicPlatform([PrincipalType.USER]),
},
schema: {
querystring: ListOAuth2AppRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ActivepiecesError, ApFlagId, CreateTemplateRequestBody, ErrorCode, Temp
import { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox'
import { Type } from '@sinclair/typebox'
import { flagService } from '../../../../flags/flag.service'
import { migrateFlowVersionTemplateList } from '../../../../flows/flow-version/migrations'
import { templateService } from '../../../../template/template.service'

export const adminPlatformTemplatesCloudController: FastifyPluginAsyncTypebox = async (
Expand All @@ -29,7 +30,13 @@ export const adminPlatformTemplatesCloudController: FastifyPluginAsyncTypebox =
})


app.post('/', CreateTemplateRequest, async (request) => {
app.post('/', {
...CreateTemplateRequest,
preValidation: async (request) => {
const migratedFlows = await migrateFlowVersionTemplateList(request.body.flows ?? [])
request.body.flows = migratedFlows
},
}, async (request) => {
const { type } = request.body
if (type !== TemplateType.OFFICIAL) {
throw new ActivepiecesError({
Expand All @@ -45,7 +52,13 @@ export const adminPlatformTemplatesCloudController: FastifyPluginAsyncTypebox =
})
})

app.post('/:id', UpdateTemplateRequest, async (request) => {
app.post('/:id', {
...UpdateTemplateRequest,
preValidation: async (request) => {
const migratedFlows = await migrateFlowVersionTemplateList(request.body.flows ?? [])
request.body.flows = migratedFlows
},
}, async (request) => {
const template = await templateService(app.log).getOneOrThrow({ id: request.params.id })

if (template.type !== TemplateType.OFFICIAL) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const flowMigrations = {
},
}

export const migrateFlowVersionTemplate = async (trigger: FlowVersion['trigger'], schemaVersion: FlowVersion['schemaVersion'], notes: FlowVersion['notes']): Promise<FlowVersionTemplate> => {
export const migrateFlowVersionTemplate = async ({ trigger, schemaVersion, notes, valid }: Pick<FlowVersionTemplate, 'trigger' | 'schemaVersion' | 'notes' | 'valid'>): Promise<FlowVersionTemplate> => {
return flowMigrations.apply({
agentIds: [],
connectionIds: [],
Expand All @@ -59,10 +59,16 @@ export const migrateFlowVersionTemplate = async (trigger: FlowVersion['trigger']
id: '',
updated: new Date().toISOString(),
updatedBy: '',
valid: false,
valid,
trigger,
state: FlowVersionState.DRAFT,
schemaVersion,
notes,
notes: notes ?? [],
})
}

export const migrateFlowVersionTemplateList = async (flowVersions: FlowVersionTemplate[]): Promise<FlowVersionTemplate[]> => {
return Promise.all(flowVersions.map(async (flowVersion) => {
return migrateFlowVersionTemplate(flowVersion)
}))
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ export const migrateV12FixPieceVersion: Migration = {
}

const flow = await flowService(system.globalLogger()).getOneById(flowVersion.flowId)
assertNotNullOrUndefined(flow, 'Flow not found')
if (isNil(flow)) {
return {
...flowVersion,
schemaVersion: '13',
}
}
const platformId = await projectService.getPlatformId(flow.projectId)
const stepNameToPieceVersion: Record<string, string> = {}
const steps = flowStructureUtil.getAllSteps(flowVersion.trigger)
Expand Down
7 changes: 6 additions & 1 deletion packages/server/api/src/app/flows/flow/flow.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ export const flowController: FastifyPluginAsyncTypebox = async (app) => {
},
preValidation: async (request) => {
if (request.body?.type === FlowOperationType.IMPORT_FLOW) {
const migratedFlowTemplate = await migrateFlowVersionTemplate(request.body.request.trigger, request.body.request.schemaVersion, request.body.request.notes ?? [])
const migratedFlowTemplate = await migrateFlowVersionTemplate({
trigger: request.body.request.trigger,
schemaVersion: request.body.request.schemaVersion,
notes: request.body.request.notes ?? [],
valid: false,
})
request.body.request = {
...request.body.request,
trigger: migratedFlowTemplate.trigger,
Expand Down
1 change: 1 addition & 0 deletions packages/server/api/src/app/template/template-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function createMinimalFlowVersion(template: FlowVersionTemplate): FlowVersion {
agentIds: [],
connectionIds: [],
backupFiles: null,
notes: template.notes ?? [],
}
}

Expand Down
19 changes: 8 additions & 11 deletions packages/server/api/src/app/template/template.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ApFlagId,
CreateTemplateRequestBody,
ErrorCode,
FlowVersionTemplate,
isNil,
ListTemplatesRequestQuery,
Principal,
Expand All @@ -22,7 +21,7 @@ import { FastifyBaseLogger } from 'fastify'
import { StatusCodes } from 'http-status-codes'
import { platformMustBeOwnedByCurrentUser } from '../ee/authentication/ee-authorization'
import { flagService } from '../flags/flag.service'
import { migrateFlowVersionTemplate } from '../flows/flow-version/migrations'
import { migrateFlowVersionTemplateList } from '../flows/flow-version/migrations'
import { system } from '../helper/system/system'
import { platformService } from '../platform/platform.service'
import { communityTemplates } from './community-flow-template.service'
Expand Down Expand Up @@ -71,14 +70,7 @@ export const templateController: FastifyPluginAsyncTypebox = async (app) => {
app.post('/', {
...CreateParams,
preValidation: async (request) => {
const migratedFlows = await Promise.all((request.body.flows ?? []).map(async (flow: FlowVersionTemplate) => {
const migratedFlow = await migrateFlowVersionTemplate(flow.trigger, flow.schemaVersion, flow.notes)
return {
...flow,
trigger: migratedFlow.trigger,
schemaVersion: migratedFlow.schemaVersion,
}
}))
const migratedFlows = await migrateFlowVersionTemplateList(request.body.flows ?? [])
request.body.flows = migratedFlows
},
}, async (request, reply) => {
Expand Down Expand Up @@ -106,7 +98,12 @@ export const templateController: FastifyPluginAsyncTypebox = async (app) => {
return reply.status(StatusCodes.CREATED).send(result)
})

app.post('/:id', UpdateParams, async (request, reply) => {
app.post('/:id', { ...UpdateParams,
preValidation: async (request) => {
const migratedFlows = await migrateFlowVersionTemplateList(request.body.flows ?? [])
request.body.flows = migratedFlows
},
}, async (request, reply) => {
const result = await templateService(app.log).update({ id: request.params.id, params: request.body })
return reply.status(StatusCodes.OK).send(result)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ describe('OAuth App API', () => {
it('should list OAuth Apps by platform member', async () => {
// arrange
const { mockPlatform: mockPlatformOne } = await mockAndSaveBasicSetup()
const { mockOwner: mockUserTwo, mockPlatform: mockPlatformTwo } = await mockAndSaveBasicSetup()
const { mockPlatform: mockPlatformTwo } = await mockAndSaveBasicSetup()
const { mockUser: mockUserTwo } = await mockBasicUser({
user: {
platformId: mockPlatformTwo.id,
platformRole: PlatformRole.MEMBER,
},
})

const mockOAuthAppsOne = await createMockOAuthApp({
platformId: mockPlatformOne.id,
Expand All @@ -211,7 +217,7 @@ describe('OAuth App API', () => {
const testToken = await generateMockToken({
type: PrincipalType.USER,
id: mockUserTwo.id,
platform: { id: mockPlatformOne.id },
platform: { id: mockPlatformTwo.id },
})
// act
const response = await app?.inject({
Expand All @@ -227,7 +233,7 @@ describe('OAuth App API', () => {

expect(response?.statusCode).toBe(StatusCodes.OK)
expect(responseBody.data).toHaveLength(1)
expect(responseBody.data[0].id).toBe(mockOAuthAppsOne.id)
expect(responseBody.data[0].id).toBe(mockOAuthAppsTwo.id)
expect(responseBody.data[0].clientSecret).toBeUndefined()
})
})
Expand Down
2 changes: 1 addition & 1 deletion packages/server/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"typings": "./src/index.d.ts",
"dependencies": {
"@activepieces/pieces-framework": "0.23.0",
"@activepieces/shared": "0.30.4",
"@activepieces/shared": "0.31.1",
"tslib": "2.6.2",
"pino": "10.1.0",
"@hyperdx/node-opentelemetry": "0.8.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@activepieces/pieces-framework": "0.23.0",
"@activepieces/server-shared": "0.0.2",
"@activepieces/shared": "0.31.0",
"@activepieces/shared": "0.31.1",
"write-file-atomic": "5.0.1",
"tslib": "2.6.2",
"@opentelemetry/api": "1.9.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@activepieces/shared",
"version": "0.31.0",
"version": "0.31.1",
"type": "commonjs"
}
5 changes: 4 additions & 1 deletion packages/shared/src/lib/template/template.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Omit, Static, Type } from '@sinclair/typebox'
import { BaseModelSchema, ColorHex, Metadata, Nullable } from '../common'
import { Note } from '../flows'
import { FlowVersion } from '../flows/flow-version'

export const TemplateTag = Type.Object({
Expand All @@ -18,9 +19,11 @@ export enum TemplateType {

export const FlowVersionTemplate = Type.Composite([Type.Omit(
FlowVersion,
['id', 'created', 'updated', 'flowId', 'state', 'updatedBy', 'agentIds', 'connectionIds', 'backupFiles'],
['id', 'created', 'updated', 'flowId', 'state', 'updatedBy', 'agentIds', 'connectionIds', 'backupFiles', 'notes'],
), Type.Object({
description: Type.Optional(Type.String()),
//notes were optional for old json templates
notes: Type.Optional(Type.Array(Note)),
})])
export type FlowVersionTemplate = Static<typeof FlowVersionTemplate>

Expand Down
Loading