missing files
This commit is contained in:
parent
ca3a1cfed9
commit
cf75b4220a
14 changed files with 0 additions and 363 deletions
|
@ -1,58 +0,0 @@
|
|||
import { CallbackStrategyWithEmpty, CoreHttpController } from "../../core/controllers/http_controller";
|
||||
import { Result } from "../../core/helpers/result";
|
||||
import { EXEC_TYPE } from "../../core/models/exec_error_model";
|
||||
import { ExecutorResult } from "../../core/models/executor_result";
|
||||
import { IPipeline, IssueType, StackGenerateType } from "../../core/models/process_model";
|
||||
import { StackService } from "../../core/services/stack_service";
|
||||
import { TriggerType } from "../_triggers/models/trigger_database_model";
|
||||
|
||||
class NixStoreModel {}
|
||||
|
||||
const getNixStoreFolderCommand: IPipeline[] = [
|
||||
{
|
||||
process: {
|
||||
type: EXEC_TYPE.EXEC,
|
||||
command: `ls /nix/store`,
|
||||
isGenerating: true,
|
||||
isLocaleCode: false,
|
||||
issueType: IssueType.WARNING,
|
||||
},
|
||||
trigger: {
|
||||
type: TriggerType.FILE,
|
||||
value: ["context"],
|
||||
},
|
||||
env: null,
|
||||
stackGenerateType: StackGenerateType.SINGLETON,
|
||||
},
|
||||
];
|
||||
class GetNixStorePackagesUseCase extends CallbackStrategyWithEmpty {
|
||||
call = async () => {
|
||||
const stackService = new StackService(
|
||||
getNixStoreFolderCommand,
|
||||
"/Users/idontsudo/Desktop/testdeck-mocha-seed/server/build/test/"
|
||||
);
|
||||
stackService.call();
|
||||
|
||||
const promise = new Promise((resolve, _reject) => {
|
||||
stackService.on((e) => {
|
||||
const iteration = e.firstElement();
|
||||
if (iteration.result instanceof ExecutorResult) {
|
||||
const nixPackage = iteration.result.data;
|
||||
resolve(nixPackage.split("\n").filter((e) => e.hasNoPattern(".drv")));
|
||||
} else {
|
||||
return "GetNixStorePackagesUseCase unknown Error";
|
||||
}
|
||||
});
|
||||
});
|
||||
return Result.ok(await promise);
|
||||
};
|
||||
}
|
||||
|
||||
export class NixStoreManagerPresentation extends CoreHttpController<NixStoreModel> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "nix_store_api",
|
||||
});
|
||||
super.get(new GetNixStorePackagesUseCase().call);
|
||||
}
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
import { Schema, model } from "mongoose";
|
||||
import { IPipeline } from "../../../core/models/process_model";
|
||||
import { schemaProcess } from "../../_process/models/process_database_model";
|
||||
import { triggerSchema } from "../../_triggers/models/trigger_database_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,
|
||||
},
|
||||
stackGenerateType: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
}).plugin(require("mongoose-autopopulate"));
|
||||
|
||||
export const schemaPipeline = "Pipeline";
|
||||
|
||||
export const PipelineDBModel = model<IPipeline>(schemaPipeline, PipelineSchema);
|
|
@ -1,21 +0,0 @@
|
|||
import { IsOptional, ValidateNested } from "class-validator";
|
||||
import { IPipeline, IProcess, StackGenerateType } from "../../../core/models/process_model";
|
||||
import { Type } from "class-transformer";
|
||||
import { ProcessModel } from "../../_process/models/process_validation_model";
|
||||
import { TriggerModelValidationModel } from "../../_triggers/models/trigger_validation_model";
|
||||
|
||||
export class PipelineModel implements IPipeline {
|
||||
@ValidateNested()
|
||||
@Type(() => ProcessModel)
|
||||
public process: IProcess;
|
||||
|
||||
@ValidateNested()
|
||||
@Type(() => TriggerModelValidationModel)
|
||||
public trigger: TriggerModelValidationModel;
|
||||
|
||||
@IsOptional()
|
||||
public env = null;
|
||||
|
||||
@IsOptional()
|
||||
public stackGenerateType: StackGenerateType;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
import { IsMongoId, IsOptional } from "class-validator";
|
||||
import { IProcess, StackGenerateType } from "../../../core/models/process_model";
|
||||
import { TriggerModelValidationModel } from "../../_triggers/models/trigger_validation_model";
|
||||
|
||||
export class PipelineValidationModel {
|
||||
@IsMongoId()
|
||||
public process: IProcess;
|
||||
|
||||
@IsMongoId()
|
||||
public trigger: TriggerModelValidationModel;
|
||||
|
||||
@IsOptional()
|
||||
public env = null;
|
||||
|
||||
@IsOptional()
|
||||
public stackGenerateType: StackGenerateType;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { PipelineDBModel } from "./models/pipeline_database_model";
|
||||
import { PipelineValidationModel } from "./models/pipeline_validation_model";
|
||||
|
||||
export class PipelinePresentation extends CrudController<PipelineValidationModel, typeof PipelineDBModel> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "pipeline",
|
||||
validationModel: PipelineValidationModel,
|
||||
databaseModel: PipelineDBModel,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
import { Schema, model } from "mongoose";
|
||||
import { IProcess } from "../../../core/models/process_model";
|
||||
|
||||
export const ProcessSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
},
|
||||
description: {
|
||||
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);
|
|
@ -1,31 +0,0 @@
|
|||
import { IsBoolean, IsEnum, IsNumber, IsOptional, IsString } from "class-validator";
|
||||
import { EXEC_TYPE } from "../../../core/models/exec_error_model";
|
||||
import { IProcess, IssueType } from "../../../core/models/process_model";
|
||||
|
||||
export class ProcessModel implements IProcess {
|
||||
@IsEnum(EXEC_TYPE)
|
||||
public type: EXEC_TYPE;
|
||||
|
||||
@IsString()
|
||||
public description: string;
|
||||
|
||||
@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;
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { ProcessDBModel } from "./models/process_database_model";
|
||||
import { ProcessModel } from "./models/process_validation_model";
|
||||
|
||||
export class ProcessPresentation extends CrudController<ProcessModel, typeof ProcessDBModel> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "process",
|
||||
validationModel: ProcessModel,
|
||||
databaseModel: ProcessDBModel,
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import { Result } from "../../../core/helpers/result";
|
||||
import { ActivePipeline } from "../../../core/models/active_pipeline_model";
|
||||
import { pipelineRealTimeService } from "../realtime_presentation";
|
||||
|
||||
export class PipelineStatusUseCase {
|
||||
async call(): Promise<Result<Error, ActivePipeline>> {
|
||||
try {
|
||||
const status = pipelineRealTimeService.status;
|
||||
if (status.projectId !== null) {
|
||||
return Result.ok(status);
|
||||
}
|
||||
|
||||
if (status.projectId === null) {
|
||||
return Result.error(new Error("pipelineRealTimeService does not have an active project instance"));
|
||||
}
|
||||
} catch (error) {
|
||||
return Result.error(error as Error);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
import { App } from "../../../core/controllers/app";
|
||||
import { CallbackStrategyWithEmpty } from "../../../core/controllers/http_controller";
|
||||
import { Result } from "../../../core/helpers/result";
|
||||
import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_by_id_database_model_usecase";
|
||||
import { IProjectModel, ProjectDBModel } from "../../projects/models/project_model_database_model";
|
||||
import { pipelineRealTimeService } from "../realtime_presentation";
|
||||
import { PipelineStatusUseCase } from "./pipeline_status_usecase";
|
||||
|
||||
|
||||
export class RunInstancePipelineUseCase extends CallbackStrategyWithEmpty {
|
||||
async call(): Promise<Result<any, string>> {
|
||||
return (await new PipelineStatusUseCase().call()).map(async (activePipelineModel) => {
|
||||
if (activePipelineModel.pipelineIsRunning) {
|
||||
return Result.error("pipeline is running");
|
||||
}
|
||||
const readByIdDataBaseModelUseCase = await new ReadByIdDataBaseModelUseCase<IProjectModel>(
|
||||
ProjectDBModel
|
||||
).call(activePipelineModel.projectId);
|
||||
|
||||
if (readByIdDataBaseModelUseCase.isFailure()) {
|
||||
return readByIdDataBaseModelUseCase.forward();
|
||||
}
|
||||
const projectModel = readByIdDataBaseModelUseCase.value;
|
||||
|
||||
pipelineRealTimeService.setPipelineDependency(
|
||||
App.staticFilesStoreDir() + projectModel.rootDir + "/",
|
||||
projectModel._id,
|
||||
projectModel.rootDir
|
||||
);
|
||||
|
||||
pipelineRealTimeService.runPipeline();
|
||||
return Result.ok("ok");
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
import { IsString } from "class-validator";
|
||||
import { CoreHttpController } from "../../core/controllers/http_controller";
|
||||
import { PipelineRealTimeService } from "../../core/services/pipeline_real_time_service";
|
||||
import { RunInstancePipelineUseCase } from "./domain/run_instance_pipeline_usecase";
|
||||
import { PipelineStatusUseCase } from "./domain/pipeline_status_usecase";
|
||||
|
||||
export const pipelineRealTimeService = new PipelineRealTimeService();
|
||||
|
||||
export class RealTimeValidationModel {
|
||||
@IsString()
|
||||
public id: string;
|
||||
}
|
||||
|
||||
export class RealTimePresentation extends CoreHttpController<RealTimeValidationModel> {
|
||||
constructor() {
|
||||
super({
|
||||
validationModel: RealTimeValidationModel,
|
||||
url: "realtime",
|
||||
databaseModel: null,
|
||||
});
|
||||
super.get(new PipelineStatusUseCase().call);
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "run",
|
||||
fn: new RunInstancePipelineUseCase(),
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
import { Schema, model } from "mongoose";
|
||||
|
||||
export interface ITriggerModel {
|
||||
_id?: string;
|
||||
type: string;
|
||||
description: string;
|
||||
value: string[];
|
||||
}
|
||||
|
||||
export const TriggerSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
require: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
},
|
||||
value: {
|
||||
type: Array,
|
||||
require: true,
|
||||
},
|
||||
});
|
||||
|
||||
export const triggerSchema = "Trigger";
|
||||
|
||||
export const TriggerDBModel = model<ITriggerModel>(triggerSchema, TriggerSchema);
|
||||
|
||||
export enum TriggerType {
|
||||
PROCESS = "PROCESS",
|
||||
FILE = "FILE",
|
||||
}
|
||||
|
||||
export interface Trigger {
|
||||
type: TriggerType;
|
||||
value: string[];
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
import { IsArray, IsOptional, IsEnum, IsString } from "class-validator";
|
||||
import { ITriggerModel, TriggerType } from "./trigger_database_model";
|
||||
|
||||
export class TriggerModelValidationModel implements ITriggerModel {
|
||||
@IsOptional()
|
||||
public _id: string;
|
||||
|
||||
@IsString()
|
||||
public description;
|
||||
|
||||
@IsEnum(TriggerType)
|
||||
public type: TriggerType;
|
||||
|
||||
@IsArray()
|
||||
public value: string[];
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { TriggerDBModel } from "./models/trigger_database_model";
|
||||
import { TriggerModelValidationModel } from "./models/trigger_validation_model";
|
||||
|
||||
// export class TriggerPresentation extends CrudController<TriggerModelValidationModel, typeof TriggerDBModel> {
|
||||
// constructor() {
|
||||
// super({
|
||||
// url: "trigger",
|
||||
// validationModel: TriggerModelValidationModel,
|
||||
// databaseModel: TriggerDBModel,
|
||||
// });
|
||||
// }
|
||||
// }
|
Loading…
Add table
Add a link
Reference in a new issue