Workflow run over a list of records + backfill availability on manual triggers (#14761)

- Allow to run workflow on a list of records
- Use new availability in manual trigger when iterator feature flag is
enabled
- Build a command to backfill availability in workflow trigger



https://github.com/user-attachments/assets/d685c01f-4059-4647-92a1-f5f529b560cf
This commit is contained in:
Thomas Trompette
2025-09-29 15:45:51 +02:00
committed by GitHub
parent 59be3aab19
commit 4329501743
17 changed files with 285 additions and 85 deletions
@@ -1,10 +1,11 @@
import { Module } from '@nestjs/common';
import { WorkflowSchemaWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-schema/workflow-schema.workspace-service';
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
import { WorkflowCommonModule } from 'src/modules/workflow/common/workflow-common.module';
import { WorkflowSchemaWorkspaceService } from 'src/modules/workflow/workflow-builder/workflow-schema/workflow-schema.workspace-service';
@Module({
imports: [WorkflowCommonModule],
imports: [WorkflowCommonModule, FeatureFlagModule],
providers: [WorkflowSchemaWorkspaceService],
exports: [WorkflowSchemaWorkspaceService],
})
@@ -12,6 +12,8 @@ import {
import { type DatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/enums/database-event-action';
import { checkStringIsDatabaseEventAction } from 'src/engine/api/graphql/graphql-query-runner/utils/check-string-is-database-event-action';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
import { generateFakeValue } from 'src/engine/utils/generate-fake-value';
import { WorkflowCommonWorkspaceService } from 'src/modules/workflow/common/workspace-services/workflow-common.workspace-service';
import { DEFAULT_ITERATOR_CURRENT_ITEM } from 'src/modules/workflow/workflow-builder/workflow-schema/constants/default-iterator-current-item.const';
@@ -38,6 +40,7 @@ import {
export class WorkflowSchemaWorkspaceService {
constructor(
private readonly workflowCommonWorkspaceService: WorkflowCommonWorkspaceService,
private readonly featureFlagService: FeatureFlagService,
) {}
async computeStepOutputSchema({
@@ -59,8 +62,21 @@ export class WorkflowSchemaWorkspaceService {
});
}
case WorkflowTriggerType.MANUAL: {
const isIteratorEnabled =
await this.featureFlagService.isFeatureEnabled(
FeatureFlagKey.IS_WORKFLOW_ITERATOR_ENABLED,
workspaceId,
);
const { objectType, availability } = step.settings;
if (isDefined(availability) && isIteratorEnabled) {
return this.computeTriggerOutputSchemaFromAvailability({
availability,
workspaceId,
});
}
// TODO: to be deprecated once all triggers are migrated to the new availability type
if (isDefined(objectType)) {
return this.computeRecordOutputSchema({
@@ -69,13 +85,6 @@ export class WorkflowSchemaWorkspaceService {
});
}
if (isDefined(availability)) {
return this.computeTriggerOutputSchemaFromAvailability({
availability,
workspaceId,
});
}
return {};
}
case WorkflowTriggerType.WEBHOOK:
@@ -291,7 +300,7 @@ export class WorkflowSchemaWorkspaceService {
);
return {
[availability.objectNameSingular]: {
[objectMetadataInfo.objectMetadataItemWithFieldsMaps.namePlural]: {
label:
objectMetadataInfo.objectMetadataItemWithFieldsMaps.labelPlural,
isLeaf: true,
@@ -2,7 +2,6 @@ import { Scope } from '@nestjs/common';
import { isDefined } from 'twenty-shared/utils';
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';
import { Processor } from 'src/engine/core-modules/message-queue/decorators/processor.decorator';
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
@@ -37,7 +36,6 @@ export class RunWorkflowJob {
private readonly twentyConfigService: TwentyConfigService,
private readonly metricsService: MetricsService,
private readonly workflowRunQueueWorkspaceService: WorkflowRunQueueWorkspaceService,
private readonly featureFlagService: FeatureFlagService,
) {}
@Process(RunWorkflowJob.name)
@@ -1,7 +1,6 @@
import { Module } from '@nestjs/common';
import { BillingModule } from 'src/engine/core-modules/billing/billing.module';
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
import { MetricsModule } from 'src/engine/core-modules/metrics/metrics.module';
import { ThrottlerModule } from 'src/engine/core-modules/throttler/throttler.module';
import { WorkflowCommonModule } from 'src/modules/workflow/common/workflow-common.module';
@@ -21,7 +20,6 @@ import { WorkflowRunnerWorkspaceService } from 'src/modules/workflow/workflow-ru
WorkflowRunModule,
MetricsModule,
WorkflowRunQueueModule,
FeatureFlagModule,
WorkflowVersionStepModule,
],
providers: [WorkflowRunnerWorkspaceService, RunWorkflowJob],