model filling
This commit is contained in:
parent
c27c061c15
commit
6ca82f8c2e
29 changed files with 245 additions and 132 deletions
|
@ -1,19 +0,0 @@
|
|||
import { IsArray, IsString, IsOptional } from "class-validator";
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
export interface ICompositionModel {
|
||||
|
||||
}
|
||||
|
||||
export const CompositionSchema = new Schema({
|
||||
|
||||
});
|
||||
|
||||
const schema = "Composition";
|
||||
|
||||
export const CompositionDBModel = model<ICompositionModel>(schema, CompositionSchema);
|
||||
|
||||
export class CompositionModel implements ICompositionModel {
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { CompositionDBModel, CompositionModel } from "./composition_model";
|
||||
|
||||
export class CompositionPresentation extends CrudController<
|
||||
CompositionModel,
|
||||
typeof CompositionDBModel
|
||||
> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "compositions",
|
||||
validationModel: CompositionModel,
|
||||
databaseModel: CompositionDBModel,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import { IsArray, IsString, IsOptional } from "class-validator";
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
export interface IFunctionsModel {
|
||||
|
||||
}
|
||||
|
||||
export const FunctionsSchema = new Schema({
|
||||
|
||||
});
|
||||
|
||||
const schema = "Functions";
|
||||
|
||||
export const FunctionsDBModel = model<IFunctionsModel>(schema, FunctionsSchema);
|
||||
|
||||
export class FunctionsModel implements IFunctionsModel {
|
||||
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { FunctionsDBModel, FunctionsModel } from "./functions_model";
|
||||
|
||||
export class FunctionsPresentation extends CrudController<
|
||||
FunctionsModel,
|
||||
typeof FunctionsDBModel
|
||||
> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "functions",
|
||||
validationModel: FunctionsModel,
|
||||
databaseModel: FunctionsDBModel,
|
||||
});
|
||||
}
|
||||
}
|
47
server/src/features/pipelines/pipeline_model.ts
Normal file
47
server/src/features/pipelines/pipeline_model.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
import { IsMongoId, IsEnum } from "class-validator";
|
||||
import { Schema, model } from "mongoose";
|
||||
import { StackGenerateType } from "../../core/model/process_model";
|
||||
import {
|
||||
TriggerModel,
|
||||
triggerSchema,
|
||||
} from "../triggers/trigger_model";
|
||||
import { schemaProcess } from "../process/process_model";
|
||||
|
||||
export const PipelineSchema = new Schema({
|
||||
process: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: schemaProcess,
|
||||
autopopulate: true,
|
||||
default: null,
|
||||
},
|
||||
trigger: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: triggerSchema,
|
||||
autopopulate: true,
|
||||
default: null,
|
||||
},
|
||||
command: {
|
||||
type: String,
|
||||
},
|
||||
}).plugin(require("mongoose-autopopulate"));
|
||||
|
||||
export const schemaPipeline = "Pipeline";
|
||||
|
||||
export const PipelineDBModel = model<PipelineModel>(
|
||||
schemaPipeline,
|
||||
PipelineSchema
|
||||
);
|
||||
|
||||
export class PipelineModel {
|
||||
@IsMongoId()
|
||||
public process: PipelineModel;
|
||||
|
||||
@IsMongoId()
|
||||
//TODO(IDONTSUDO):NEED OPTION DECORATOR??
|
||||
public trigger: TriggerModel;
|
||||
|
||||
public env = null;
|
||||
|
||||
@IsEnum(StackGenerateType)
|
||||
public stackGenerateType: StackGenerateType;
|
||||
}
|
16
server/src/features/pipelines/pipeline_presentation.ts
Normal file
16
server/src/features/pipelines/pipeline_presentation.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { PipelineDBModel, PipelineModel } from "./pipeline_model";
|
||||
|
||||
export class PipelinePresentation extends CrudController<
|
||||
PipelineModel,
|
||||
typeof PipelineDBModel
|
||||
> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "pipeline",
|
||||
validationModel: PipelineModel,
|
||||
databaseModel: PipelineDBModel,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
74
server/src/features/process/process_model.ts
Normal file
74
server/src/features/process/process_model.ts
Normal file
|
@ -0,0 +1,74 @@
|
|||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
ValidateNested,
|
||||
IsEnum,
|
||||
IsMongoId,
|
||||
IsNumber,
|
||||
IsBoolean,
|
||||
} from "class-validator";
|
||||
import { ObjectId, Schema, model } from "mongoose";
|
||||
import {
|
||||
IProcess,
|
||||
IPipeline,
|
||||
IssueType,
|
||||
StackGenerateType,
|
||||
} from "../../core/model/process_model";
|
||||
import { Type } from "class-transformer";
|
||||
import { EXEC_TYPE } from "../../core/model/exec_error_model";
|
||||
|
||||
export const ProcessSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
},
|
||||
command: {
|
||||
type: String,
|
||||
},
|
||||
isGenerating: {
|
||||
type: String,
|
||||
},
|
||||
isLocaleCode: {
|
||||
type: String,
|
||||
},
|
||||
issueType: {
|
||||
type: String,
|
||||
},
|
||||
timeout: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
commit: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
export const schemaProcess = "Process";
|
||||
|
||||
export const ProcessDBModel = model<IProcess>(schemaProcess, ProcessSchema);
|
||||
|
||||
export class ProcessModel implements IProcess {
|
||||
@IsEnum(EXEC_TYPE)
|
||||
public type: EXEC_TYPE;
|
||||
|
||||
@IsString()
|
||||
public command: string;
|
||||
|
||||
@IsBoolean()
|
||||
public isGenerating: boolean;
|
||||
|
||||
@IsBoolean()
|
||||
public isLocaleCode: boolean;
|
||||
|
||||
@IsEnum(IssueType)
|
||||
public issueType: IssueType;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
public timeout?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
public commit?: string;
|
||||
}
|
||||
|
15
server/src/features/process/process_presentation.ts
Normal file
15
server/src/features/process/process_presentation.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { ProcessDBModel, ProcessModel } from "./process_model";
|
||||
|
||||
export class ProcessPresentation extends CrudController<
|
||||
ProcessModel,
|
||||
typeof ProcessDBModel
|
||||
> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "process",
|
||||
validationModel: ProcessModel,
|
||||
databaseModel: ProcessDBModel,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,14 +1,42 @@
|
|||
import { IsArray, IsString, IsOptional } from "class-validator";
|
||||
import { Schema, model } from "mongoose";
|
||||
import mongoose, { Schema, model } from "mongoose";
|
||||
import { PipelineModel, schemaPipeline } from "../pipelines/pipeline_model";
|
||||
|
||||
export interface IProjectModel {
|
||||
pipelines: [PipelineModel];
|
||||
rootDir: string;
|
||||
}
|
||||
|
||||
export interface IProjectModel {}
|
||||
|
||||
export const ProjectSchema = new Schema({
|
||||
|
||||
});
|
||||
pipelines: {
|
||||
type: Array<Schema.Types.ObjectId>,
|
||||
ref: schemaPipeline,
|
||||
autopopulate: true,
|
||||
default: null,
|
||||
},
|
||||
rootDir: {
|
||||
type: String,
|
||||
},
|
||||
}).plugin(require("mongoose-autopopulate"));
|
||||
|
||||
const schema = "Projects";
|
||||
|
||||
export const ProjectDBModel = model<IProjectModel>(schema, ProjectSchema);
|
||||
|
||||
export class ProjectModel implements IProjectModel {}
|
||||
export class ProjectModel implements IProjectModel {
|
||||
pipelines: [PipelineModel];
|
||||
rootDir: string;
|
||||
}
|
||||
|
||||
// export class ProcessModel implements IProcessMetaData {
|
||||
|
||||
// public process: IProcess;
|
||||
|
||||
// public trigger: ObjectId;
|
||||
|
||||
// // TODO(IDONTSUDO): later, when maintaining many environments, you will need to make a table
|
||||
// public env = null;
|
||||
|
||||
// @IsEnum(StackGenerateType)
|
||||
// public stackGenerateType: StackGenerateType;
|
||||
// }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { IsArray, IsString, IsOptional } from "class-validator";
|
||||
import { IsArray, IsOptional, IsEnum} from "class-validator";
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
export interface ITriggerModel {
|
||||
|
@ -18,16 +18,20 @@ export const TriggerSchema = new Schema({
|
|||
},
|
||||
});
|
||||
|
||||
const schema = "Trigger";
|
||||
export const triggerSchema = "Trigger";
|
||||
|
||||
export const TriggerDBModel = model<ITriggerModel>(schema, TriggerSchema);
|
||||
export const TriggerDBModel = model<ITriggerModel>(triggerSchema, TriggerSchema);
|
||||
|
||||
export enum TriggerType {
|
||||
PROCESS = "PROCESS",
|
||||
FILE = "FILE",
|
||||
}
|
||||
|
||||
export class TriggerModel implements ITriggerModel {
|
||||
@IsOptional()
|
||||
public _id: string;
|
||||
@IsString()
|
||||
public type: string;
|
||||
|
||||
@IsEnum(TriggerType)
|
||||
public type: TriggerType;
|
||||
@IsArray()
|
||||
public value: string[];
|
||||
}
|
||||
|
@ -36,8 +40,4 @@ export interface Trigger {
|
|||
type: TriggerType;
|
||||
value: string[];
|
||||
}
|
||||
|
||||
export enum TriggerType {
|
||||
PROCESS = "PROCESS",
|
||||
FILE = "FILE",
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue