feat: Return scopes on executions (no-changelog) (#10310)

This commit is contained in:
Val
2024-08-07 10:19:09 +01:00
committed by GitHub
parent 6d8323fade
commit fa17391dbd
10 changed files with 94 additions and 4 deletions

View File

@@ -40,6 +40,8 @@ import { QueuedExecutionRetryError } from '@/errors/queued-execution-retry.error
import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service';
import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error';
import { License } from '@/License';
import type { User } from '@/databases/entities/User';
import { WorkflowSharingService } from '@/workflows/workflowSharing.service';
export const schemaGetExecutionsQueryFilter = {
$id: '/IGetExecutionsQueryFilter',
@@ -92,6 +94,7 @@ export class ExecutionService {
private readonly workflowRunner: WorkflowRunner,
private readonly concurrencyControl: ConcurrencyControlService,
private readonly license: License,
private readonly workflowSharingService: WorkflowSharingService,
) {}
async findOne(
@@ -478,4 +481,16 @@ export class ExecutionService {
return await this.executionRepository.stopDuringRun(execution);
}
async addScopes(user: User, summaries: ExecutionSummaries.ExecutionSummaryWithScopes[]) {
const workflowIds = [...new Set(summaries.map((s) => s.workflowId))];
const scopes = Object.fromEntries(
await this.workflowSharingService.getSharedWorkflowScopes(workflowIds, user),
);
for (const s of summaries) {
s.scopes = scopes[s.workflowId] ?? [];
}
}
}