Skip to content

Commit

Permalink
fix: fixed extraction of workflow's ui definition (#2608)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blokh authored Aug 4, 2024
1 parent 48c56ad commit 5d9a1f6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion services/workflows-service/prisma/data-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { WorkflowService } from '@/workflow/workflow.service';
import { AnyRecord } from '@ballerine/common';
import { BUILT_IN_EVENT } from '@ballerine/workflow-core';
import { Injectable } from '@nestjs/common';
import { EndUser, UiDefinition, UiDefinitionContext, WorkflowRuntimeData } from '@prisma/client';
import { EndUser, Prisma, UiDefinition, WorkflowRuntimeData } from '@prisma/client';
import { randomUUID } from 'crypto';
import get from 'lodash/get';

Expand Down Expand Up @@ -75,22 +75,23 @@ export class CollectionFlowService {
}

async getFlowConfiguration(
configurationId: string,
workflowDefinitionId: string,
context: WorkflowRuntimeData['context'],
language: string,
projectIds: TProjectIds,
args?: Prisma.UiDefinitionFindFirstOrThrowArgs,
): Promise<FlowConfigurationModel> {
const workflowDefinition = await this.workflowService.getWorkflowDefinitionById(
configurationId,
workflowDefinitionId,
{},
projectIds,
);

const uiDefintion = await this.uiDefinitionService.getByWorkflowDefinitionId(
workflowDefinition.id,
'collection_flow' as keyof typeof UiDefinitionContext,
'collection_flow' as const,
projectIds,
{},
args,
);

const translationService = new TranslationService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export class UiDefinitionControllerInternal {
params.workflowDefinitionId,
params.uiContext,
projectIds,
{},
);

return uiDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,22 @@ export class UiDefinitionRepository {
async findByWorkflowDefinitionId(
workflowDefinitionId: string,
uiContext: keyof typeof UiDefinitionContext,
args: Prisma.UiDefinitionFindFirstOrThrowArgs,
projectIds: TProjectIds,
args?: Prisma.UiDefinitionFindFirstOrThrowArgs,
): Promise<UiDefinition> {
return await this.prisma.uiDefinition.findFirstOrThrow(
this.scopeService.scopeFindFirst(
{
...args,
where: {
workflowDefinitionId,
uiContext: uiContext,
...args?.where,
or: [
{
workflowDefinitionId,
uiContext: uiContext,
},
...(args?.where ? [args.where] : []),
],
},
...args,
},
projectIds,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export class UiDefinitionService {
workflowDefinitionId: string,
uiContext: keyof typeof UiDefinitionContext,
projectIds: TProjectIds,
args: Prisma.UiDefinitionFindFirstOrThrowArgs,
args?: Prisma.UiDefinitionFindFirstOrThrowArgs,
) {
return await this.repository.findByWorkflowDefinitionId(
workflowDefinitionId,
uiContext,
args,
projectIds,
args,
);
}

Expand All @@ -52,9 +52,7 @@ export class UiDefinitionService {

return this.getByWorkflowDefinitionId(runtime.workflowDefinitionId, uiContext, projectIds, {
...args,
where: {
...(runtime.uiDefinitionId ? { id: runtime.uiDefinitionId } : {}),
},
...(runtime.uiDefinitionId ? { where: { id: runtime.uiDefinitionId } } : {}),
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,6 @@ export class WorkflowService {
workflowDefinitionId,
UiDefinitionContext.collection_flow,
projectIds,
{},
);
} catch (err) {
if (isErrorWithMessage(err)) {
Expand Down

0 comments on commit 5d9a1f6

Please sign in to comment.