feat: add create or update workflow trigger (#14708)

### Description

This PR focuses on
https://github.com/twentyhq/core-team-issues/issues/1476

- introduces the handling of upserted events in the workflow trigger
system


## Visual Appearance
<img width="1792" height="1039" alt="Screenshot 2025-09-21 at 11 40
28 PM"
src="https://github.com/user-attachments/assets/d926b566-f7d3-412b-b1ab-ed2064425f3d"
/>

<img width="501" height="1025" alt="Screenshot 2025-09-21 at 11 40
39 PM"
src="https://github.com/user-attachments/assets/13c3031a-0762-4c80-8df1-fa74ca70a540"
/>


### Changes
- Added `UPSERTED` action to the `DatabaseEventAction` enum.
- Updated the `WorkflowEditTriggerDatabaseEventForm` to support upserted
events.

---------

Co-authored-by: Thomas Trompette <thomas.trompette@sfr.fr>
This commit is contained in:
Harshit Singh
2025-10-01 18:47:05 +05:30
committed by GitHub
parent b5e6703f35
commit ae4a93c993
22 changed files with 213 additions and 16 deletions
@@ -168,6 +168,14 @@ export class WorkspaceInsertQueryBuilder<
authContext: this.authContext,
});
await this.internalContext.eventEmitterService.emitMutationEvent({
action: DatabaseEventAction.UPSERTED,
objectMetadataItem: objectMetadata,
workspaceId: this.internalContext.workspaceId,
entities: formattedResultForEvent,
authContext: this.authContext,
});
// TypeORM returns all entity columns for insertions
const resultWithoutInsertionExtraColumns = !isDefined(result.raw)
? []
@@ -161,6 +161,15 @@ export class WorkspaceUpdateQueryBuilder<
authContext: this.authContext,
});
await this.internalContext.eventEmitterService.emitMutationEvent({
action: DatabaseEventAction.UPSERTED,
objectMetadataItem: objectMetadata,
workspaceId: this.internalContext.workspaceId,
entities: formattedAfter,
beforeEntities: formattedBefore,
authContext: this.authContext,
});
const formattedResult = formatResult<T[]>(
result.raw,
objectMetadata,
@@ -293,6 +302,15 @@ export class WorkspaceUpdateQueryBuilder<
authContext: this.authContext,
});
await this.internalContext.eventEmitterService.emitMutationEvent({
action: DatabaseEventAction.UPSERTED,
objectMetadataItem: objectMetadata,
workspaceId: this.internalContext.workspaceId,
entities: formattedAfter,
beforeEntities: formattedBefore,
authContext: this.authContext,
});
const formattedResults = formatResult<T[]>(
results.flatMap((result) => result.raw),
objectMetadata,