2024-07-17 15:53:01 +00:00
|
|
|
import {
|
2025-01-17 13:49:02 +00:00
|
|
|
Check,
|
2024-07-17 15:53:01 +00:00
|
|
|
Column,
|
|
|
|
|
CreateDateColumn,
|
|
|
|
|
Entity,
|
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
|
UpdateDateColumn,
|
|
|
|
|
} from 'typeorm';
|
|
|
|
|
|
2024-12-13 10:16:29 +00:00
|
|
|
import { InputSchema } from 'src/modules/workflow/workflow-builder/types/input-schema.type';
|
2024-11-05 13:57:06 +00:00
|
|
|
|
2025-01-17 13:49:02 +00:00
|
|
|
const DEFAULT_SERVERLESS_TIMEOUT_SECONDS = 300; // 5 minutes
|
|
|
|
|
|
2024-07-17 15:53:01 +00:00
|
|
|
export enum ServerlessFunctionSyncStatus {
|
|
|
|
|
NOT_READY = 'NOT_READY',
|
2025-01-31 16:12:42 +00:00
|
|
|
BUILDING = 'BUILDING',
|
2024-07-17 15:53:01 +00:00
|
|
|
READY = 'READY',
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 11:03:09 +00:00
|
|
|
export enum ServerlessFunctionRuntime {
|
|
|
|
|
NODE18 = 'nodejs18.x',
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-17 15:53:01 +00:00
|
|
|
@Entity('serverlessFunction')
|
|
|
|
|
export class ServerlessFunctionEntity {
|
|
|
|
|
@PrimaryGeneratedColumn('uuid')
|
|
|
|
|
id: string;
|
|
|
|
|
|
|
|
|
|
@Column({ nullable: false })
|
|
|
|
|
name: string;
|
|
|
|
|
|
2024-07-29 11:03:09 +00:00
|
|
|
@Column({ nullable: true })
|
|
|
|
|
description: string;
|
|
|
|
|
|
2024-08-23 10:06:03 +00:00
|
|
|
@Column({ nullable: true })
|
|
|
|
|
latestVersion: string;
|
2024-07-17 15:53:01 +00:00
|
|
|
|
2024-10-22 12:51:03 +00:00
|
|
|
@Column({ nullable: false, type: 'jsonb', default: [] })
|
|
|
|
|
publishedVersions: string[];
|
|
|
|
|
|
2024-11-05 13:57:06 +00:00
|
|
|
@Column({ nullable: true, type: 'jsonb' })
|
2024-11-08 16:15:27 +00:00
|
|
|
latestVersionInputSchema: InputSchema;
|
2024-11-05 13:57:06 +00:00
|
|
|
|
2024-07-29 11:03:09 +00:00
|
|
|
@Column({ nullable: false, default: ServerlessFunctionRuntime.NODE18 })
|
|
|
|
|
runtime: ServerlessFunctionRuntime;
|
|
|
|
|
|
2025-01-17 13:49:02 +00:00
|
|
|
@Column({ nullable: false, default: DEFAULT_SERVERLESS_TIMEOUT_SECONDS })
|
|
|
|
|
@Check(`"timeoutSeconds" >= 1 AND "timeoutSeconds" <= 900`)
|
|
|
|
|
timeoutSeconds: number;
|
|
|
|
|
|
2024-09-02 13:25:20 +00:00
|
|
|
@Column({ nullable: true })
|
|
|
|
|
layerVersion: number;
|
|
|
|
|
|
2024-07-17 15:53:01 +00:00
|
|
|
@Column({
|
|
|
|
|
nullable: false,
|
|
|
|
|
default: ServerlessFunctionSyncStatus.NOT_READY,
|
|
|
|
|
type: 'enum',
|
|
|
|
|
enum: ServerlessFunctionSyncStatus,
|
|
|
|
|
})
|
|
|
|
|
syncStatus: ServerlessFunctionSyncStatus;
|
|
|
|
|
|
|
|
|
|
@Column({ nullable: false, type: 'uuid' })
|
|
|
|
|
workspaceId: string;
|
|
|
|
|
|
|
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
|
|
|
|
createdAt: Date;
|
|
|
|
|
|
|
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
|
|
|
updatedAt: Date;
|
|
|
|
|
}
|