From 48cf5eab8a69aa913746b61c798d721834cd9b1d Mon Sep 17 00:00:00 2001 From: GalT <39020298+tatarco@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:41:35 +0100 Subject: [PATCH] bug(api): api compiles --- .../app/bridge/usecases/sync/sync.usecase.ts | 11 +++++---- .../shared/map-step-type-to-output.mapper.ts | 14 +++++------ ...ailable-variable-schema-usecase.service.ts | 24 +++++++++++-------- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/apps/api/src/app/bridge/usecases/sync/sync.usecase.ts b/apps/api/src/app/bridge/usecases/sync/sync.usecase.ts index ed9ea7701fcd..b4e96c0e46d6 100644 --- a/apps/api/src/app/bridge/usecases/sync/sync.usecase.ts +++ b/apps/api/src/app/bridge/usecases/sync/sync.usecase.ts @@ -21,10 +21,11 @@ import { UpsertWorkflowPreferencesCommand, } from '@novu/application-generic'; import { + JSONSchemaDto, WorkflowCreationSourceEnum, WorkflowOriginEnum, - WorkflowTypeEnum, WorkflowPreferencesPartial, + WorkflowTypeEnum, } from '@novu/shared'; import { DiscoverOutput, DiscoverStepOutput, DiscoverWorkflowOutput, GetActionEnum } from '@novu/framework/internal'; @@ -208,10 +209,10 @@ export class Sync { __source: WorkflowCreationSourceEnum.BRIDGE, steps: this.mapSteps(workflow.steps), controls: { - schema: workflow.controls?.schema, + schema: workflow.controls?.schema as JSONSchemaDto, }, rawData: workflow as unknown as Record, - payloadSchema: workflow.payload?.schema, + payloadSchema: workflow.payload?.schema as JSONSchemaDto, active: isWorkflowActive, description: this.getWorkflowDescription(workflow), data: this.castToAnyNotSupportedParam(workflow)?.data, @@ -237,10 +238,10 @@ export class Sync { workflowId: workflow.workflowId, steps: this.mapSteps(workflow.steps, workflowExist), controls: { - schema: workflow.controls?.schema, + schema: workflow.controls?.schema as JSONSchemaDto, }, rawData: workflow, - payloadSchema: workflow.payload?.schema, + payloadSchema: workflow.payload?.schema as unknown as JSONSchemaDto, type: WorkflowTypeEnum.BRIDGE, description: this.getWorkflowDescription(workflow), data: this.castToAnyNotSupportedParam(workflow)?.data, diff --git a/apps/api/src/app/workflows-v2/shared/map-step-type-to-output.mapper.ts b/apps/api/src/app/workflows-v2/shared/map-step-type-to-output.mapper.ts index cc75b3604233..a21cbe751dc8 100644 --- a/apps/api/src/app/workflows-v2/shared/map-step-type-to-output.mapper.ts +++ b/apps/api/src/app/workflows-v2/shared/map-step-type-to-output.mapper.ts @@ -1,5 +1,5 @@ import { ActionStepEnum, actionStepSchemas, ChannelStepEnum, channelStepSchemas } from '@novu/framework/internal'; -import { ControlSchemas } from '@novu/shared'; +import { ControlSchemas, JSONSchemaDto } from '@novu/shared'; import { EmailStepControlSchema, EmailStepUiSchema, inAppControlSchema, InAppUiSchema } from './schemas'; export const PERMISSIVE_EMPTY_SCHEMA = { @@ -19,22 +19,22 @@ export const stepTypeToDefaultDashboardControlSchema: Record = {}; - previousStepsProperties = (previousSteps || []).reduce( +function buildPreviousStepsProperties( + previousSteps: NotificationStepEntity[] | undefined, + payloadSchema?: JSONSchemaDto +) { + return (previousSteps || []).reduce( (acc, step) => { if (step.stepId && step.template?.type) { acc[step.stepId] = computeResultSchema(step.template.type, payloadSchema); @@ -37,16 +37,21 @@ function buildPreviousStepsSchema(previousSteps: NotificationStepEntity[] | unde return acc; }, - {} as Record + {} as Record ); +} +function buildPreviousStepsSchema( + previousSteps: NotificationStepEntity[] | undefined, + payloadSchema?: JSONSchemaDto +): JSONSchemaDto { return { type: 'object', - properties: previousStepsProperties, + properties: buildPreviousStepsProperties(previousSteps, payloadSchema), required: [], additionalProperties: false, description: 'Previous Steps Results', - } as const satisfies JSONSchema; + } as const satisfies JSONSchemaDto; } const buildSubscriberSchema = () => ({ @@ -67,6 +72,5 @@ const buildSubscriberSchema = () => description: 'The last time the subscriber was online (optional)', }, }, - required: ['firstName', 'lastName', 'email', 'subscriberId'], additionalProperties: false, }) as const satisfies JSONSchemaDto;