2024-01-16 08:10:14 +00:00
|
|
|
import {
|
|
|
|
Entity,
|
2024-02-05 09:26:28 +00:00
|
|
|
PrimaryColumn,
|
2024-01-16 08:10:14 +00:00
|
|
|
Column,
|
|
|
|
CreateDateColumn,
|
|
|
|
UpdateDateColumn,
|
|
|
|
ManyToOne,
|
|
|
|
OneToOne,
|
|
|
|
JoinColumn
|
|
|
|
} from 'typeorm';
|
|
|
|
|
|
|
|
import { Project } from './Project';
|
|
|
|
import { Domain } from './Domain';
|
2024-01-30 10:18:50 +00:00
|
|
|
import { User } from './User';
|
2024-02-21 04:00:14 +00:00
|
|
|
import { AppDeploymentRecordAttributes } from '../types';
|
2024-01-16 08:10:14 +00:00
|
|
|
|
2024-01-25 05:47:44 +00:00
|
|
|
export enum Environment {
|
2024-01-16 08:10:14 +00:00
|
|
|
Production = 'Production',
|
|
|
|
Preview = 'Preview',
|
|
|
|
Development = 'Development',
|
|
|
|
}
|
|
|
|
|
2024-02-12 06:04:01 +00:00
|
|
|
export enum DeploymentStatus {
|
2024-01-16 08:10:14 +00:00
|
|
|
Building = 'Building',
|
|
|
|
Ready = 'Ready',
|
|
|
|
Error = 'Error',
|
|
|
|
}
|
|
|
|
|
2024-02-12 06:04:01 +00:00
|
|
|
export interface ApplicationRecord {
|
|
|
|
type: string;
|
|
|
|
version:string
|
2024-02-21 04:00:14 +00:00
|
|
|
name: string
|
2024-02-14 05:33:22 +00:00
|
|
|
description?: string
|
|
|
|
homepage?: string
|
|
|
|
license?: string
|
|
|
|
author?: string
|
|
|
|
repository?: string[],
|
|
|
|
app_version?: string
|
2024-02-12 06:04:01 +00:00
|
|
|
repository_ref: string
|
|
|
|
app_type: string
|
|
|
|
}
|
|
|
|
|
2024-01-16 08:10:14 +00:00
|
|
|
@Entity()
|
|
|
|
export class Deployment {
|
2024-02-05 09:26:28 +00:00
|
|
|
// TODO: set custom generated id
|
|
|
|
@PrimaryColumn('varchar')
|
|
|
|
id!: string;
|
2024-01-16 08:10:14 +00:00
|
|
|
|
2024-02-21 04:00:14 +00:00
|
|
|
@Column()
|
|
|
|
projectId!: string;
|
|
|
|
|
2024-01-16 08:10:14 +00:00
|
|
|
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
|
2024-01-17 04:32:06 +00:00
|
|
|
@JoinColumn({ name: 'projectId' })
|
2024-01-16 08:10:14 +00:00
|
|
|
project!: Project;
|
|
|
|
|
2024-02-15 11:54:57 +00:00
|
|
|
@Column({ nullable: true })
|
|
|
|
domainId!: string | null;
|
|
|
|
|
2024-01-16 08:10:14 +00:00
|
|
|
@OneToOne(() => Domain)
|
2024-01-17 04:32:06 +00:00
|
|
|
@JoinColumn({ name: 'domainId' })
|
2024-01-25 12:04:13 +00:00
|
|
|
domain!: Domain | null;
|
2024-01-16 08:10:14 +00:00
|
|
|
|
|
|
|
@Column('varchar')
|
|
|
|
branch!: string;
|
|
|
|
|
|
|
|
@Column('varchar')
|
|
|
|
commitHash!: string;
|
|
|
|
|
2024-02-14 08:55:50 +00:00
|
|
|
@Column('varchar')
|
|
|
|
commitMessage!: string;
|
|
|
|
|
2024-02-21 04:00:14 +00:00
|
|
|
@Column('varchar', { nullable: true })
|
|
|
|
url!: string | null;
|
2024-01-16 08:10:14 +00:00
|
|
|
|
2024-02-05 09:26:28 +00:00
|
|
|
@Column('varchar')
|
2024-02-21 04:00:14 +00:00
|
|
|
applicationRecordId!: string;
|
2024-02-12 06:04:01 +00:00
|
|
|
|
|
|
|
@Column('simple-json')
|
2024-02-21 04:00:14 +00:00
|
|
|
applicationRecordData!: ApplicationRecord;
|
|
|
|
|
|
|
|
@Column('varchar', { nullable: true })
|
|
|
|
applicationDeploymentRecordId!: string | null;
|
|
|
|
|
|
|
|
@Column('simple-json', { nullable: true })
|
|
|
|
applicationDeploymentRecordData!: AppDeploymentRecordAttributes | null;
|
2024-02-05 09:26:28 +00:00
|
|
|
|
2024-01-16 08:10:14 +00:00
|
|
|
@Column({
|
|
|
|
enum: Environment
|
|
|
|
})
|
|
|
|
environment!: Environment;
|
|
|
|
|
|
|
|
@Column('boolean', { default: false })
|
|
|
|
isCurrent!: boolean;
|
|
|
|
|
|
|
|
@Column({
|
2024-02-12 06:04:01 +00:00
|
|
|
enum: DeploymentStatus
|
2024-01-16 08:10:14 +00:00
|
|
|
})
|
2024-02-12 06:04:01 +00:00
|
|
|
status!: DeploymentStatus;
|
2024-01-16 08:10:14 +00:00
|
|
|
|
2024-01-30 10:18:50 +00:00
|
|
|
@ManyToOne(() => User)
|
|
|
|
@JoinColumn({ name: 'createdBy' })
|
|
|
|
createdBy!: User;
|
|
|
|
|
2024-01-16 08:10:14 +00:00
|
|
|
@CreateDateColumn()
|
|
|
|
createdAt!: Date;
|
|
|
|
|
|
|
|
@UpdateDateColumn()
|
|
|
|
updatedAt!: Date;
|
|
|
|
}
|