Skip to content

Commit

Permalink
Merge branch 'main' into use-lock-in-storage-service
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud authored Feb 20, 2024
2 parents 5a4406a + f619ed8 commit d8bf5ce
Show file tree
Hide file tree
Showing 219 changed files with 3,912 additions and 906 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,15 @@
"contributions": [
"plugin"
]
},
{
"login": "Verlich",
"name": "Ahmad(Ed)",
"avatar_url": "https://avatars.githubusercontent.com/u/30838131?v=4",
"profile": "https://github.com/Verlich",
"contributions": [
"plugin"
]
}
],
"commitType": "docs"
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tmp
firebase-admin-sdk.json
dev
cache
.env

# SDK Build
builds
Expand All @@ -23,7 +24,7 @@ node_modules
*.launch
.settings/
*.sublime-workspace

cache
# IDE - VSCode
.vscode/*
!.vscode/settings.json
Expand Down Expand Up @@ -60,3 +61,4 @@ activepieces-engine.js
scratch.md

# environment variables
.env
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if git diff --cached --name-only -- packages/server/api/.env | grep -q '^package
exit 1
fi

npx --no -- commitlint --edit ${1}
npx --no -- commitlint --edit ${1}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ Not into coding but still interested in contributing? Come join our [Discord](ht
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AdamSelene"><img src="https://avatars.githubusercontent.com/u/79495?v=4?s=100" width="100px;" alt="Olivier Sambourg"/><br /><sub><b>Olivier Sambourg</b></sub></a><br /><a href="#plugin-AdamSelene" title="Plugin/utility libraries">🔌</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Verlich"><img src="https://avatars.githubusercontent.com/u/30838131?v=4?s=100" width="100px;" alt="Ahmad(Ed)"/><br /><sub><b>Ahmad(Ed)</b></sub></a><br /><a href="#plugin-Verlich" title="Plugin/utility libraries">🔌</a></td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.0'
services:
activepieces:
image: ghcr.io/activepieces/activepieces:0.20.0
image: ghcr.io/activepieces/activepieces:0.20.2
container_name: activepieces
restart: unless-stopped
## Enable the following line if you already use AP_EXECUTION_MODE with SANDBOXED or old activepieces, checking the breaking change documentation for more info.
Expand Down
27 changes: 23 additions & 4 deletions docs/developers/piece-reference/flow-control.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: 'Flow Control'
icon: 'joystick'
description: 'Learn How to control flow from inside the piece'
icon: 'Joystick'
description: 'Learn How to Control Flow from Inside the Piece'
---

Flow Controls provide the ability to control the flow of execution from inside a piece. By using the `ctx` parameter in the `run` method of actions, you can perform various operations to control the flow.

## Stop Flow

You can stop the flow and provide a response to the webhook trigger, This can be useful when you want to terminate the execution of the piece and send a specific response back.
You can stop the flow and provide a response to the webhook trigger. This can be useful when you want to terminate the execution of the piece and send a specific response back.

**Example with Response:**

Expand All @@ -28,7 +28,26 @@ context.run.stop({
context.run.stop();
```

## Pause / Delay Flow
## Pause Flow and Wait for Webhook

You can pause flow and return HTTP response, also provide a callback to URL that you can call with certain payload and continue the flow.

**Example:**

```typescript
ctx.run.pause({
pauseMetadata: {
type: PauseType.WEBHOOK,
response: {
callbackUrl: context.generateResumeUrl({
queryParams: {},
}),
},
},
});
```

## Pause Flow and Delay

You can pause or delay the flow until a specific timestamp. Currently, the only supported type of pause is a delay based on a future timestamp.

Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.20.0",
"version": "0.20.2",
"rcVersion": "0.21.0-rc.0",
"scripts": {
"prepare": "husky install",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class ShareFlowTemplateDialogComponent {
) {
this.show$ = this.flagsService
.getEdition()
.pipe(map((ed) => ed === ApEdition.CLOUD));
.pipe(map((ed) => ed === ApEdition.ENTERPRISE || ed === ApEdition.CLOUD));
this.isPublicTemplatesProject$ = combineLatest({
templateProjectId: this.flagsService.getAllFlags().pipe(
map((flags) => {
Expand All @@ -96,11 +96,11 @@ export class ShareFlowTemplateDialogComponent {
if (!this.loading) {
this.loading = true;
const request: CreateFlowTemplateRequest = {
description: this.form.value.description,
template: this.flow.version,
type: TemplateType.PROJECT,
blogUrl: this.form.value.blogUrl,
tags: this.form.value.tags,
description: this.form.value.description,
};
this.telemetryService.capture({
name: TelemetryEventName.FLOW_SHARED,
Expand Down Expand Up @@ -145,7 +145,6 @@ export class ShareFlowTemplateDialogComponent {
tap((template) => {
if (template) {
this.form.patchValue({
description: template.description,
blogUrl: template.blogUrl,
tags: template.tags,
});
Expand Down
86 changes: 83 additions & 3 deletions packages/ee/shared/src/lib/audit-events/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Static, Type } from "@sinclair/typebox";
import { BaseModelSchema } from "@activepieces/shared";
import { BaseModelSchema, FlowOperationRequest, FlowOperationType } from "@activepieces/shared";
export const ListAuditEventsRequest = Type.Object({
limit: Type.Optional( Type.Number()),
limit: Type.Optional(Type.Number()),
cursor: Type.Optional(Type.String()),
})

Expand All @@ -13,6 +13,7 @@ export enum ApplicationEventName {
CREATED_FOLDER = 'CREATED_FOLDER',
UPDATED_FOLDER = 'UPDATED_FOLDER',
DELETED_FOLDER = 'DELETED_FOLDER',
UPDATED_FLOW = 'UPDATED_FLOW',
UPSERTED_CONNECTION = 'UPSERTED_CONNECTION',
DELETED_CONNECTION = 'DELETED_CONNECTION',
SIGNED_IN = 'SIGNED_IN',
Expand Down Expand Up @@ -57,7 +58,10 @@ export type FolderEvent = Static<typeof FolderEvent>

export const FlowEvent = Type.Object({
...BaseAuditEventProps,
action: Type.Union([Type.Literal(ApplicationEventName.CREATED_FLOW), Type.Literal(ApplicationEventName.DELETED_FLOW)]),
action: Type.Union([
Type.Literal(ApplicationEventName.CREATED_FLOW),
Type.Literal(ApplicationEventName.DELETED_FLOW),
]),
data: Type.Object({
flowId: Type.String(),
flowName: Type.String(),
Expand All @@ -66,6 +70,18 @@ export const FlowEvent = Type.Object({

export type FlowEvent = Static<typeof FlowEvent>

export const UpdatedFlowEvent = Type.Object({
...BaseAuditEventProps,
action: Type.Literal(ApplicationEventName.UPDATED_FLOW),
data: Type.Object({
flowId: Type.String(),
flowName: Type.String(),
request: FlowOperationRequest
}),
})

export type UpdatedFlowEvent = Static<typeof UpdatedFlowEvent>

export const AuthenticationEvent = Type.Object({
...BaseAuditEventProps,
action: Type.Union([Type.Literal(ApplicationEventName.SIGNED_UP), Type.Literal(ApplicationEventName.SIGNED_IN), Type.Literal(ApplicationEventName.RESET_PASSWORD), Type.Literal(ApplicationEventName.VERIFIED_EMAIL)]),
Expand All @@ -79,7 +95,71 @@ export const ApplicationEvent = Type.Union([
FlowEvent,
AuthenticationEvent,
FolderEvent,
UpdatedFlowEvent,
])

export type ApplicationEvent = Static<typeof ApplicationEvent>


export function summarizeApplicationEvent(event: ApplicationEvent) {
switch (event.action) {
case ApplicationEventName.UPDATED_FLOW: {
return convertUpdateActionToDetails(event);
}
case ApplicationEventName.CREATED_FLOW:
return `${event.data.flowName} is created`;
case ApplicationEventName.DELETED_FLOW:
return `${event.data.flowName} is deleted`;
case ApplicationEventName.CREATED_FOLDER:
return `${event.data.folderName} is created`;
case ApplicationEventName.UPDATED_FOLDER:
return `${event.data.folderName} is updated`;
case ApplicationEventName.DELETED_FOLDER:
return `${event.data.folderName} is deleted`;
case ApplicationEventName.UPSERTED_CONNECTION:
return `${event.data.connectionName} is updated`;
case ApplicationEventName.DELETED_CONNECTION:
return `${event.data.connectionName} is deleted`;
case ApplicationEventName.SIGNED_UP:
return `User ${event.userEmail} signed up`;
case ApplicationEventName.SIGNED_IN:
return `User ${event.userEmail} signed in`;
case ApplicationEventName.RESET_PASSWORD:
return `User ${event.userEmail} reset password`;
case ApplicationEventName.VERIFIED_EMAIL:
return `User ${event.userEmail} verified email`;
}
}

function convertUpdateActionToDetails(event: UpdatedFlowEvent) {
switch (event.data.request.type) {
case FlowOperationType.ADD_ACTION:
return `Added action "${event.data.request.request.action.displayName}" to "${event.data.flowName}" Flow.`;
case FlowOperationType.UPDATE_ACTION:
return `Updated action "${event.data.request.request.displayName}" in "${event.data.flowName}" Flow.`;
case FlowOperationType.DELETE_ACTION:
return `Deleted action "${event.data.request.request.name}" from "${event.data.flowName}" Flow.`;
case FlowOperationType.CHANGE_NAME:
return `Renamed flow "${event.data.flowName}" to "${event.data.request.request.displayName}".`;
case FlowOperationType.LOCK_AND_PUBLISH:
return `Locked and published flow "${event.data.flowName}" Flow.`;
case FlowOperationType.USE_AS_DRAFT:
return `Unlocked and unpublished flow "${event.data.flowName}" Flow.`;
case FlowOperationType.MOVE_ACTION:
return `Moved action "${event.data.request.request.name}" to after "${event.data.request.request.newParentStep}".`;
case FlowOperationType.LOCK_FLOW:
return `Locked flow "${event.data.flowName}" Flow.`;
case FlowOperationType.CHANGE_STATUS:
return `Changed status of flow "${event.data.flowName}" Flow to "${event.data.request.request.status}".`;
case FlowOperationType.DUPLICATE_ACTION:
return `Duplicated action "${event.data.request.request.stepName}" in "${event.data.flowName}" Flow.`;
case FlowOperationType.IMPORT_FLOW:
return `Imported flow in "${event.data.request.request.displayName}" Flow.`;
case FlowOperationType.UPDATE_TRIGGER:
return `Updated trigger in "${event.data.flowName}" Flow to "${event.data.request.request.displayName}".`;
case FlowOperationType.CHANGE_FOLDER:
return `Moved flow "${event.data.flowName}" to folder id ${event.data.request.request.folderId}.`;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {
ApplicationEvent,
ApplicationEventName,
Platform,
summarizeApplicationEvent,
} from '@activepieces/ee-shared';
import { ActivatedRoute } from '@angular/router';

@Component({
selector: 'app-audit-event-table',
Expand Down Expand Up @@ -45,7 +47,10 @@ export class AuditEventTableComponent
dialogClosed$?: Observable<unknown>;
featureDisabledTooltip = featureDisabledTooltip;

constructor(private auditEventService: AuditEventService) {
constructor(
private auditEventService: AuditEventService,
private activatedRoute: ActivatedRoute
) {
super();
}
ngOnInit(): void {
Expand All @@ -60,7 +65,8 @@ export class AuditEventTableComponent
this.refresh$.asObservable().pipe(startWith(false)),
this.auditEventService,
this.paginator,
this.isEnabled$
this.isEnabled$,
this.activatedRoute.queryParams
);
}

Expand All @@ -76,6 +82,7 @@ export class AuditEventTableComponent
case ApplicationEventName.CREATED_FLOW:
case ApplicationEventName.DELETED_FLOW:
case ApplicationEventName.CREATED_FOLDER:
case ApplicationEventName.UPDATED_FLOW:
return {
icon: 'assets/img/custom/dashboard/flows.svg',
tooltip: 'Flow',
Expand Down Expand Up @@ -104,29 +111,6 @@ export class AuditEventTableComponent
}

convertToDetails(event: ApplicationEvent) {
switch (event.action) {
case ApplicationEventName.CREATED_FLOW:
return `${event.data.flowName} is created`;
case ApplicationEventName.DELETED_FLOW:
return `${event.data.flowName} is deleted`;
case ApplicationEventName.CREATED_FOLDER:
return `${event.data.folderName} is created`;
case ApplicationEventName.UPDATED_FOLDER:
return `${event.data.folderName} is updated`;
case ApplicationEventName.DELETED_FOLDER:
return `${event.data.folderName} is deleted`;
case ApplicationEventName.UPSERTED_CONNECTION:
return `${event.data.connectionName} is updated`;
case ApplicationEventName.DELETED_CONNECTION:
return `${event.data.connectionName} is deleted`;
case ApplicationEventName.SIGNED_UP:
return `User ${event.userEmail} signed up`;
case ApplicationEventName.SIGNED_IN:
return `User ${event.userEmail} signed in`;
case ApplicationEventName.RESET_PASSWORD:
return `User ${event.userEmail} reset password`;
case ApplicationEventName.VERIFIED_EMAIL:
return `User ${event.userEmail} verified email`;
}
return summarizeApplicationEvent(event);
}
}
Loading

0 comments on commit d8bf5ce

Please sign in to comment.