Files
twenty/packages/twenty-server/src/engine/metadata-modules/logic-function/logic-function.entity.ts
T
martmull 9162685b2e Reorganize logic function files (#17766)
reorganize according to

<img width="1243" height="725" alt="Pasted Graphic"
src="https://github.com/user-attachments/assets/ba65dd10-8eec-4b13-ad49-9726edd3b79c"
/>

Not working yet
2026-02-09 12:36:39 +01:00

89 lines
2.5 KiB
TypeScript

import {
Check,
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import {
CronTriggerSettings,
DatabaseEventTriggerSettings,
HttpRouteTriggerSettings,
} from 'twenty-shared/application';
import { SyncableEntity } from 'src/engine/workspace-manager/types/syncable-entity.interface';
import { type JsonbProperty } from 'src/engine/workspace-manager/workspace-migration/universal-flat-entity/types/jsonb-property.type';
const DEFAULT_LOGIC_FUNCTION_TIMEOUT_SECONDS = 300; // 5 minutes
export enum LogicFunctionRuntime {
NODE18 = 'nodejs18.x',
NODE22 = 'nodejs22.x',
}
export const DEFAULT_SOURCE_HANDLER_PATH = 'src/index.ts';
export const DEFAULT_BUILT_HANDLER_PATH = 'src/index.mjs';
export const DEFAULT_HANDLER_NAME = 'main';
@Entity('logicFunction')
@Index('IDX_LOGIC_FUNCTION_ID_DELETED_AT', ['id', 'deletedAt'])
export class LogicFunctionEntity
extends SyncableEntity
implements Required<LogicFunctionEntity>
{
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: false })
name: string;
@Column({ nullable: false, default: DEFAULT_SOURCE_HANDLER_PATH })
sourceHandlerPath: string;
@Column({ nullable: false, default: DEFAULT_BUILT_HANDLER_PATH })
builtHandlerPath: string;
@Column({ nullable: false, default: DEFAULT_HANDLER_NAME })
handlerName: string;
@Column({ nullable: true, type: 'varchar' })
description: string | null;
@Column({ nullable: false, default: LogicFunctionRuntime.NODE22 })
runtime: LogicFunctionRuntime;
@Column({ nullable: false, default: DEFAULT_LOGIC_FUNCTION_TIMEOUT_SECONDS })
@Check(`"timeoutSeconds" >= 1 AND "timeoutSeconds" <= 900`)
timeoutSeconds: number;
@Column({ nullable: true, type: 'text' })
checksum: string | null;
@Column({ nullable: true, type: 'jsonb' })
toolInputSchema: JsonbProperty<object> | null;
@Column({ nullable: false, default: false })
isTool: boolean;
@Column({ nullable: true, type: 'jsonb' })
cronTriggerSettings: JsonbProperty<CronTriggerSettings> | null;
@Column({ nullable: true, type: 'jsonb' })
databaseEventTriggerSettings: JsonbProperty<DatabaseEventTriggerSettings> | null;
@Column({ nullable: true, type: 'jsonb' })
httpRouteTriggerSettings: JsonbProperty<HttpRouteTriggerSettings> | null;
@CreateDateColumn({ type: 'timestamptz' })
createdAt: Date;
@UpdateDateColumn({ type: 'timestamptz' })
updatedAt: Date;
@DeleteDateColumn({ type: 'timestamptz' })
deletedAt: Date | null;
}