Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6658 workflows add a first twenty piece email sender #6965

Merged
merged 24 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions packages/twenty-emails/src/emails/workflow-action.email.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { BaseEmail } from 'src/components/BaseEmail';
import { Title } from 'src/components/Title';
import { CallToAction } from 'src/components/CallToAction';

type WorkflowActionEmailProps = {
dangerousHTML?: string;
title?: string;
callToAction?: {
value: string;
href: string;
};
};
export const WorkflowActionEmail = ({
dangerousHTML,
title,
callToAction,
}: WorkflowActionEmailProps) => {
return (
<BaseEmail>
{title && <Title value={title} />}
{dangerousHTML && (
<div dangerouslySetInnerHTML={{ __html: dangerousHTML }} />
)}
{callToAction && (
<CallToAction value={callToAction.value} href={callToAction.href} />
)}
</BaseEmail>
);
};
1 change: 1 addition & 0 deletions packages/twenty-emails/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './emails/delete-inactive-workspaces.email';
export * from './emails/password-reset-link.email';
export * from './emails/password-update-notify.email';
export * from './emails/send-invite-link.email';
export * from './emails/workflow-action.email';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const ACTIONS: Array<{
}> = [
{
label: 'Serverless Function',
type: 'CODE_ACTION',
type: 'CODE',
icon: IconSettingsAutomation,
},
];
4 changes: 2 additions & 2 deletions packages/twenty-front/src/modules/workflow/types/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type WorkflowCodeSettingsType = WorkflowBaseSettingsType & {
serverlessFunctionId: string;
};

export type WorkflowActionType = 'CODE_ACTION';
export type WorkflowActionType = 'CODE';

type CommonWorkflowAction = {
id: string;
Expand All @@ -22,7 +22,7 @@ type CommonWorkflowAction = {
};

type WorkflowCodeAction = CommonWorkflowAction & {
type: 'CODE_ACTION';
type: 'CODE';
settings: WorkflowCodeSettingsType;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('addCreateStepNodes', () => {
{
id: 'step1',
name: 'Step 1',
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
settings: {
errorHandlingOptions: {
Expand All @@ -27,7 +27,7 @@ describe('addCreateStepNodes', () => {
{
id: 'step2',
name: 'Step 2',
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
settings: {
errorHandlingOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('generateWorkflowDiagram', () => {
{
id: 'step1',
name: 'Step 1',
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
settings: {
errorHandlingOptions: {
Expand All @@ -48,7 +48,7 @@ describe('generateWorkflowDiagram', () => {
{
id: 'step2',
name: 'Step 2',
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
settings: {
errorHandlingOptions: {
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('generateWorkflowDiagram', () => {
{
id: 'step1',
name: 'Step 1',
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
settings: {
errorHandlingOptions: {
Expand All @@ -101,7 +101,7 @@ describe('generateWorkflowDiagram', () => {
{
id: 'step2',
name: 'Step 2',
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
settings: {
errorHandlingOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('getWorkflowVersionDiagram', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
};

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
};

Expand Down Expand Up @@ -97,7 +97,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
},
{
Expand All @@ -110,7 +110,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
},
],
Expand All @@ -131,7 +131,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
};

Expand Down Expand Up @@ -167,7 +167,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
},
{
Expand All @@ -180,7 +180,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
},
],
Expand All @@ -201,7 +201,7 @@ describe('insertStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('replaceStep', () => {
},
serverlessFunctionId: 'first',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
} satisfies WorkflowStep;
const workflowVersionInitial = {
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('replaceStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
};
const workflowVersionInitial = {
Expand All @@ -79,7 +79,7 @@ describe('replaceStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
},
stepToBeReplaced,
Expand All @@ -93,7 +93,7 @@ describe('replaceStep', () => {
},
serverlessFunctionId: 'a5434be2-c10b-465c-acec-46492782a997',
},
type: 'CODE_ACTION',
type: 'CODE',
valid: true,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ export const generateWorkflowDiagram = ({
},
});

// Recursively generate flow for the next action if it exists
if (step.type !== 'CODE_ACTION') {
// processNode(action.nextAction, nodeId, xPos + 150, yPos + 100);

throw new Error('Other types as code actions are not supported yet.');
}

return nodeId;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const getStepDefaultDefinition = (
const newStepId = v4();

switch (type) {
case 'CODE_ACTION': {
case 'CODE': {
return {
id: newStepId,
name: 'Code',
type: 'CODE_ACTION',
type: 'CODE',
valid: false,
settings: {
serverlessFunctionId: '',
Expand Down
1 change: 1 addition & 0 deletions packages/twenty-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"cache-manager-redis-yet": "^4.1.2",
"class-validator": "patch:class-validator@0.14.0#./patches/class-validator+0.14.0.patch",
"graphql-middleware": "^6.1.35",
"handlebars": "^4.7.8",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this library? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To resolve the data injection in the html template we provide to the payload

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it!

"jsdom": "~22.1.0",
"jwt-decode": "^4.0.0",
"langchain": "^0.2.6",
Expand Down
7 changes: 2 additions & 5 deletions packages/twenty-server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ import { GraphQLConfigModule } from 'src/engine/api/graphql/graphql-config/graph
import { GraphQLConfigService } from 'src/engine/api/graphql/graphql-config/graphql-config.service';
import { MetadataGraphQLApiModule } from 'src/engine/api/graphql/metadata-graphql-api.module';
import { RestApiModule } from 'src/engine/api/rest/rest-api.module';
import { MessageQueueDriverType } from 'src/engine/integrations/message-queue/interfaces';
import { MessageQueueModule } from 'src/engine/integrations/message-queue/message-queue.module';
import { MessageQueueDriverType } from 'src/engine/core-modules/message-queue/interfaces';
import { MessageQueueModule } from 'src/engine/core-modules/message-queue/message-queue.module';
import { WorkspaceMetadataVersionModule } from 'src/engine/metadata-modules/workspace-metadata-version/workspace-metadata-version.module';
import { GraphQLHydrateRequestFromTokenMiddleware } from 'src/engine/middlewares/graphql-hydrate-request-from-token.middleware';
import { TwentyORMModule } from 'src/engine/twenty-orm/twenty-orm.module';
import { ModulesModule } from 'src/modules/modules.module';

import { CoreEngineModule } from './engine/core-modules/core-engine.module';
import { IntegrationsModule } from './engine/integrations/integrations.module';

@Module({
imports: [
Expand All @@ -47,8 +46,6 @@ import { IntegrationsModule } from './engine/integrations/integrations.module';
useClass: GraphQLConfigService,
}),
TwentyORMModule,
// Integrations module, contains all the integrations with other services
IntegrationsModule,
// Core engine module, contains all the core modules
CoreEngineModule,
// Modules module, contains all business logic modules
Expand Down
4 changes: 2 additions & 2 deletions packages/twenty-server/src/command/command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CommandFactory } from 'nest-commander';

import { ExceptionHandlerService } from 'src/engine/integrations/exception-handler/exception-handler.service';
import { LoggerService } from 'src/engine/integrations/logger/logger.service';
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
import { LoggerService } from 'src/engine/core-modules/logger/logger.service';
import { shouldFilterException } from 'src/engine/utils/global-exception-handler.util';

import { CommandModule } from './command.module';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Command, CommandRunner } from 'nest-commander';

import { dataSeedDemoWorkspaceCronPattern } from 'src/database/commands/data-seed-demo-workspace/crons/data-seed-demo-workspace-cron-pattern';
import { DataSeedDemoWorkspaceJob } from 'src/database/commands/data-seed-demo-workspace/jobs/data-seed-demo-workspace.job';
import { InjectMessageQueue } from 'src/engine/integrations/message-queue/decorators/message-queue.decorator';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';

@Command({
name: 'workspace-seed-demo:cron:start',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { Command, CommandRunner } from 'nest-commander';

import { dataSeedDemoWorkspaceCronPattern } from 'src/database/commands/data-seed-demo-workspace/crons/data-seed-demo-workspace-cron-pattern';
import { DataSeedDemoWorkspaceJob } from 'src/database/commands/data-seed-demo-workspace/jobs/data-seed-demo-workspace.job';
import { InjectMessageQueue } from 'src/engine/integrations/message-queue/decorators/message-queue.decorator';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
import { InjectMessageQueue } from 'src/engine/core-modules/message-queue/decorators/message-queue.decorator';
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';

@Command({
name: 'workspace-seed-demo:cron:stop',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';

import { EnvironmentModule } from 'src/engine/integrations/environment/environment.module';
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
import { WorkspaceManagerModule } from 'src/engine/workspace-manager/workspace-manager.module';
import { DataSeedDemoWorkspaceService } from 'src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DataSeedDemoWorkspaceService } from 'src/database/commands/data-seed-demo-workspace/services/data-seed-demo-workspace.service';
import { Processor } from 'src/engine/integrations/message-queue/decorators/processor.decorator';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { Process } from 'src/engine/integrations/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';
import { Process } from 'src/engine/core-modules/message-queue/decorators/process.decorator';

@Processor(MessageQueue.cronQueue)
export class DataSeedDemoWorkspaceJob {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';

import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { WorkspaceManagerService } from 'src/engine/workspace-manager/workspace-manager.service';
import {
deleteCoreSchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import { rawDataSource } from 'src/database/typeorm/raw/raw.datasource';
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { CacheStorageService } from 'src/engine/integrations/cache-storage/cache-storage.service';
import { InjectCacheStorage } from 'src/engine/integrations/cache-storage/decorators/cache-storage.decorator';
import { CacheStorageNamespace } from 'src/engine/integrations/cache-storage/types/cache-storage-namespace.enum';
import { CacheStorageService } from 'src/engine/core-modules/cache-storage/cache-storage.service';
import { InjectCacheStorage } from 'src/engine/core-modules/cache-storage/decorators/cache-storage.decorator';
import { CacheStorageNamespace } from 'src/engine/core-modules/cache-storage/types/cache-storage-namespace.enum';
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
import { FieldMetadataService } from 'src/engine/metadata-modules/field-metadata/field-metadata.service';
import { ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TypeORMModule } from 'src/database/typeorm/typeorm.module';
import { KeyValuePair } from 'src/engine/core-modules/key-value-pair/key-value-pair.entity';
import { OnboardingModule } from 'src/engine/core-modules/onboarding/onboarding.module';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { FileStorageModule } from 'src/engine/integrations/file-storage/file-storage.module';
import { FileStorageModule } from 'src/engine/core-modules/file-storage/file-storage.module';
import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module';
import { FieldMetadataEntity } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { FieldMetadataModule } from 'src/engine/metadata-modules/field-metadata/field-metadata.module';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { TypeOrmModule, TypeOrmModuleOptions } from '@nestjs/typeorm';

import { typeORMCoreModuleOptions } from 'src/database/typeorm/core/core.datasource';
import { EnvironmentModule } from 'src/engine/integrations/environment/environment.module';
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';

import { TypeORMService } from './typeorm.service';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';

import { DataSource } from 'typeorm';

import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
import { User } from 'src/engine/core-modules/user/user.entity';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
Expand Down
Loading
Loading