Merge remote-tracking branch 'origin/main' into 4-fix/mvp-ui
This commit is contained in:
commit
6c85616c99
9 changed files with 317 additions and 18 deletions
2
server/.gitignore
vendored
2
server/.gitignore
vendored
|
@ -8,4 +8,4 @@ package-lock.json
|
|||
.*.swp
|
||||
build/
|
||||
model_create.ts
|
||||
public
|
||||
public
|
||||
|
|
|
@ -41,4 +41,4 @@
|
|||
// return 'UnitTestEnv'
|
||||
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
20
server/src/core/usecases/read_database_model_usecase.ts
Normal file
20
server/src/core/usecases/read_database_model_usecase.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
import { Result } from "../helper/result";
|
||||
|
||||
export class ReadByIdDataBaseModelUseCase<D> {
|
||||
databaseModel: D;
|
||||
|
||||
constructor(model) {
|
||||
this.databaseModel = model;
|
||||
}
|
||||
call = async (id: string): Promise<Result<Error, D>> => {
|
||||
try {
|
||||
const r = this.databaseModel as any;
|
||||
|
||||
const model = await r.findById(id);
|
||||
return Result.ok(model);
|
||||
} catch (error) {
|
||||
return Result.error(error);
|
||||
}
|
||||
};
|
||||
}
|
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;
|
||||
}
|
69
server/src/features/process/process_model.ts
Normal file
69
server/src/features/process/process_model.ts
Normal file
|
@ -0,0 +1,69 @@
|
|||
import {
|
||||
IsString,
|
||||
IsOptional,
|
||||
IsEnum,
|
||||
IsNumber,
|
||||
IsBoolean,
|
||||
} from "class-validator";
|
||||
import { Schema, model } from "mongoose";
|
||||
import {
|
||||
IProcess,
|
||||
IssueType,
|
||||
} from "../../core/model/process_model";
|
||||
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;
|
||||
}
|
||||
|
31
server/src/features/projects/projects_model.ts
Normal file
31
server/src/features/projects/projects_model.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
import { Schema, model } from "mongoose";
|
||||
import { PipelineModel, schemaPipeline } from "../pipelines/pipeline_model";
|
||||
import { IsMongoId, IsString } from "class-validator";
|
||||
|
||||
export interface IProjectModel {
|
||||
pipelines: [PipelineModel];
|
||||
rootDir: string;
|
||||
}
|
||||
|
||||
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 {
|
||||
@IsMongoId()
|
||||
pipelines: [PipelineModel];
|
||||
@IsString()
|
||||
rootDir: string;
|
||||
}
|
43
server/src/features/triggers/trigger_model.ts
Normal file
43
server/src/features/triggers/trigger_model.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { IsArray, IsOptional, IsEnum} from "class-validator";
|
||||
import { Schema, model } from "mongoose";
|
||||
|
||||
export interface ITriggerModel {
|
||||
_id?: string;
|
||||
type: string;
|
||||
value: string[];
|
||||
}
|
||||
|
||||
export const TriggerSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
require: true,
|
||||
},
|
||||
value: {
|
||||
type: Array,
|
||||
require: true,
|
||||
},
|
||||
});
|
||||
|
||||
export const triggerSchema = "Trigger";
|
||||
|
||||
export const TriggerDBModel = model<ITriggerModel>(triggerSchema, TriggerSchema);
|
||||
|
||||
export enum TriggerType {
|
||||
PROCESS = "PROCESS",
|
||||
FILE = "FILE",
|
||||
}
|
||||
|
||||
export class TriggerModel implements ITriggerModel {
|
||||
@IsOptional()
|
||||
public _id: string;
|
||||
@IsEnum(TriggerType)
|
||||
public type: TriggerType;
|
||||
@IsArray()
|
||||
public value: string[];
|
||||
}
|
||||
|
||||
export interface Trigger {
|
||||
type: TriggerType;
|
||||
value: string[];
|
||||
}
|
||||
|
|
@ -14,12 +14,10 @@ import { UpdateDataBaseModelUseCaseTest } from "./usecases/update_database_model
|
|||
import { PaginationDataBaseModelUseCaseTest } from "./usecases/pagination_database_model_usecase_test";
|
||||
import { extensions } from "../src/core/extensions/extensions";
|
||||
import { DataBaseConnectUseCase } from "../src/core/usecases/database_connect_usecase";
|
||||
import { mainTest } from "./helper/class_validator_mocker_test";
|
||||
|
||||
extensions();
|
||||
|
||||
const testCore = TestCore.instance;
|
||||
|
||||
export const dirname__: string = dirname(__filename);
|
||||
export const assert = testCore.assert;
|
||||
export const resultTest = testCore.resultTest;
|
||||
|
@ -36,22 +34,21 @@ const init = async () => {
|
|||
};
|
||||
|
||||
const test = async () => {
|
||||
// await new ExecutorProgramServiceTest(dirname__).test();
|
||||
// await new FilesChangerTest(dirname__).test();
|
||||
// await new StackServiceTest(dirname__ + "/context/").test();
|
||||
// await new TriggerServiceTest().test();
|
||||
// await new CreateDataBaseModelUseCaseTest().test();
|
||||
await new ExecutorProgramServiceTest(dirname__).test();
|
||||
await new FilesChangerTest(dirname__).test();
|
||||
await new StackServiceTest(dirname__ + "/context/").test();
|
||||
await new TriggerServiceTest().test();
|
||||
await new CreateDataBaseModelUseCaseTest().test();
|
||||
|
||||
// await new CreateDataBaseModelUseCaseTest().test();
|
||||
// await new DeleteDataBaseModelUseCaseTest().test();
|
||||
// await new ReadDataBaseModelUseCaseTest().test();
|
||||
// await new UpdateDataBaseModelUseCaseTest().test();
|
||||
// // await new PipelineRealTimeServiceTest().test()
|
||||
// for await (const usecase of tests) {
|
||||
// testCore.assert(await new usecase().test(), usecase.name);
|
||||
// }
|
||||
await new CreateDataBaseModelUseCaseTest().test();
|
||||
await new DeleteDataBaseModelUseCaseTest().test();
|
||||
await new ReadDataBaseModelUseCaseTest().test();
|
||||
await new UpdateDataBaseModelUseCaseTest().test();
|
||||
// await new PipelineRealTimeServiceTest().test()
|
||||
for await (const usecase of tests) {
|
||||
testCore.assert(await new usecase().test(), usecase.name);
|
||||
}
|
||||
|
||||
mainTest();
|
||||
};
|
||||
const main = async () => {
|
||||
await init();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue