Skip to content

Commit

Permalink
Merge pull request #437 from Alt-Org/change/environment-var-414
Browse files Browse the repository at this point in the history
add environment variable to env vars
  • Loading branch information
MikhailDeriabin authored Feb 12, 2025
2 parents ec82455 + 7e539e0 commit 9a29e65
Show file tree
Hide file tree
Showing 13 changed files with 471 additions and 7 deletions.
110 changes: 110 additions & 0 deletions src/__tests__/box/data/box/BoxBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import {SessionStage} from "../../../../box/enum/SessionStage.enum";
import {Box} from "../../../../box/schemas/box.schema";
import {ObjectId} from "mongodb";
import {Tester} from "../../../../box/schemas/tester.schema";
import {DailyTask} from "../../../../dailyTasks/dailyTasks.schema";

export default class BoxBuilder {
private readonly base: Partial<Box> = {
adminPassword: 'defaultAdminPassword',
sessionStage: SessionStage.PREPARING,
testersSharedPassword: null,
boxRemovalTime: Date.now() + 1000000,
sessionResetTime: Date.now() + 500000,
adminProfile_id: null,
adminPlayer_id: null,
clan_ids: [],
soulHome_ids: [],
room_ids: [],
stock_ids: [],
chat_id: null,
testers: [],
accountClaimersIds: [],
dailyTasks: [],
_id: null
};

build(): Box {
return { ...this.base } as Box;
}

setAdminPassword(password: string) {
this.base.adminPassword = password;
return this;
}

setSessionStage(stage: SessionStage) {
this.base.sessionStage = stage;
return this;
}

setTestersSharedPassword(password: string | null) {
this.base.testersSharedPassword = password;
return this;
}

setBoxRemovalTime(time: number) {
this.base.boxRemovalTime = time;
return this;
}

setSessionResetTime(time: number) {
this.base.sessionResetTime = time;
return this;
}

setAdminProfileId(profileId: ObjectId) {
this.base.adminProfile_id = profileId;
return this;
}

setAdminPlayerId(playerId: ObjectId) {
this.base.adminPlayer_id = playerId;
return this;
}

setClanIds(clanIds: ObjectId[]) {
this.base.clan_ids = clanIds;
return this;
}

setSoulHomeIds(soulHomeIds: ObjectId[]) {
this.base.soulHome_ids = soulHomeIds;
return this;
}

setRoomIds(roomIds: ObjectId[]) {
this.base.room_ids = roomIds;
return this;
}

setStockIds(stockIds: ObjectId[]) {
this.base.stock_ids = stockIds;
return this;
}

setChatId(chatId: ObjectId) {
this.base.chat_id = chatId;
return this;
}

setTesters(testers: Tester[]) {
this.base.testers = testers;
return this;
}

setAccountClaimersIds(accountClaimersIds: string[]) {
this.base.accountClaimersIds = accountClaimersIds;
return this;
}

setDailyTasks(dailyTasks: DailyTask[]) {
this.base.dailyTasks = dailyTasks;
return this;
}

setId(id: ObjectId) {
this.base._id = id;
return this;
}
}
105 changes: 105 additions & 0 deletions src/__tests__/box/data/box/CreateBoxDtoBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {SessionStage} from "../../../../box/enum/SessionStage.enum";
import {ObjectId} from "mongodb";
import {Tester} from "../../../../box/schemas/tester.schema";
import {DailyTask} from "../../../../dailyTasks/dailyTasks.schema";
import {CreateBoxDto} from "../../../../box/dto/createBox.dto";


export default class CreateBoxDtoBuilder {
private readonly base: Partial<CreateBoxDto> = {
adminPassword: 'defaultAdminPassword',
sessionStage: SessionStage.PREPARING,
testersSharedPassword: null,
boxRemovalTime: Date.now() + 1000000,
sessionResetTime: Date.now() + 500000,
adminProfile_id: null,
adminPlayer_id: null,
clan_ids: [],
soulHome_ids: [],
room_ids: [],
stock_ids: [],
chat_id: null,
testers: [],
accountClaimersIds: [],
dailyTasks: [],
};

build(): CreateBoxDto {
return { ...this.base } as CreateBoxDto;
}

setAdminPassword(password: string) {
this.base.adminPassword = password;
return this;
}

setSessionStage(stage: SessionStage) {
this.base.sessionStage = stage;
return this;
}

setTestersSharedPassword(password: string | null) {
this.base.testersSharedPassword = password;
return this;
}

setBoxRemovalTime(time: number) {
this.base.boxRemovalTime = time;
return this;
}

setSessionResetTime(time: number) {
this.base.sessionResetTime = time;
return this;
}

setAdminProfileId(profileId: ObjectId) {
this.base.adminProfile_id = profileId;
return this;
}

setAdminPlayerId(playerId: ObjectId) {
this.base.adminPlayer_id = playerId;
return this;
}

setClanIds(clanIds: ObjectId[]) {
this.base.clan_ids = clanIds;
return this;
}

setSoulHomeIds(soulHomeIds: ObjectId[]) {
this.base.soulHome_ids = soulHomeIds;
return this;
}

setRoomIds(roomIds: ObjectId[]) {
this.base.room_ids = roomIds;
return this;
}

setStockIds(stockIds: ObjectId[]) {
this.base.stock_ids = stockIds;
return this;
}

setChatId(chatId: ObjectId) {
this.base.chat_id = chatId;
return this;
}

setTesters(testers: Tester[]) {
this.base.testers = testers;
return this;
}

setAccountClaimersIds(accountClaimersIds: string[]) {
this.base.accountClaimersIds = accountClaimersIds;
return this;
}

setDailyTasks(dailyTasks: DailyTask[]) {
this.base.dailyTasks = dailyTasks;
return this;
}
}
23 changes: 23 additions & 0 deletions src/__tests__/box/data/box/GroupAdminBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {ObjectId} from "mongodb";
import {GroupAdmin} from "../../../../box/schemas/groupAdmin.schema";

export default class GroupAdminBuilder {
private readonly base: Partial<GroupAdmin> = {
password: 'defaultPassword',
_id: null,
};

build(): GroupAdmin {
return { ...this.base } as GroupAdmin;
}

setPassword(password: string) {
this.base.password = password;
return this;
}

setId(id: ObjectId) {
this.base._id = id;
return this;
}
}
111 changes: 111 additions & 0 deletions src/__tests__/box/data/box/UpdateBoxDtoBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import {UpdateBoxDto} from "../../../../box/dto/updateBox.dto";
import {SessionStage} from "../../../../box/enum/SessionStage.enum";
import {ObjectId} from "mongodb";
import {Tester} from "../../../../box/schemas/tester.schema";
import {DailyTask} from "../../../../dailyTasks/dailyTasks.schema";


export default class UpdateBoxDtoBuilder {
private readonly base: Partial<UpdateBoxDto> = {
_id: null,
adminPassword: null,
sessionStage: null,
testersSharedPassword: null,
boxRemovalTime: null,
sessionResetTime: null,
adminProfile_id: null,
adminPlayer_id: null,
clan_ids: null,
soulHome_ids: null,
room_ids: null,
stock_ids: null,
chat_id: null,
testers: null,
accountClaimersIds: null,
dailyTasks: null,
};

build(): UpdateBoxDto {
return { ...this.base } as UpdateBoxDto;
}

setId(id: string) {
this.base._id = id;
return this;
}

setAdminPassword(password: string) {
this.base.adminPassword = password;
return this;
}

setSessionStage(stage: SessionStage) {
this.base.sessionStage = stage;
return this;
}

setTestersSharedPassword(password: string | null) {
this.base.testersSharedPassword = password;
return this;
}

setBoxRemovalTime(time: number) {
this.base.boxRemovalTime = time;
return this;
}

setSessionResetTime(time: number) {
this.base.sessionResetTime = time;
return this;
}

setAdminProfileId(profileId: ObjectId) {
this.base.adminProfile_id = profileId;
return this;
}

setAdminPlayerId(playerId: ObjectId) {
this.base.adminPlayer_id = playerId;
return this;
}

setClanIds(clanIds: ObjectId[]) {
this.base.clan_ids = clanIds;
return this;
}

setSoulHomeIds(soulHomeIds: ObjectId[]) {
this.base.soulHome_ids = soulHomeIds;
return this;
}

setRoomIds(roomIds: ObjectId[]) {
this.base.room_ids = roomIds;
return this;
}

setStockIds(stockIds: ObjectId[]) {
this.base.stock_ids = stockIds;
return this;
}

setChatId(chatId: ObjectId) {
this.base.chat_id = chatId;
return this;
}

setTesters(testers: Tester[]) {
this.base.testers = testers;
return this;
}

setAccountClaimersIds(accountClaimersIds: string[]) {
this.base.accountClaimersIds = accountClaimersIds;
return this;
}

setDailyTasks(dailyTasks: DailyTask[]) {
this.base.dailyTasks = dailyTasks;
return this;
}
}
31 changes: 31 additions & 0 deletions src/__tests__/box/data/boxBuilderFactory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import BoxBuilder from "./box/BoxBuilder";
import CreateBoxDtoBuilder from "./box/CreateBoxDtoBuilder";
import UpdateBoxDtoBuilder from "./box/UpdateBoxDtoBuilder";
import GroupAdminBuilder from "./box/GroupAdminBuilder";


type BuilderName = 'Box' | 'CreateBoxDto' | 'UpdateBoxDto' | 'GroupAdmin';

type BuilderMap = {
Box: BoxBuilder,
CreateBoxDto: CreateBoxDtoBuilder,
UpdateBoxDto: UpdateBoxDtoBuilder,
GroupAdmin: GroupAdminBuilder
};

export default class BoxBuilderFactory {
static getBuilder<T extends BuilderName>(builderName: T): BuilderMap[T] {
switch (builderName) {
case 'Box':
return new BoxBuilder() as BuilderMap[T];
case 'CreateBoxDto':
return new CreateBoxDtoBuilder() as BuilderMap[T];
case 'UpdateBoxDto':
return new UpdateBoxDtoBuilder() as BuilderMap[T];
case 'GroupAdmin':
return new GroupAdminBuilder() as BuilderMap[T];
default:
throw new Error(`Unknown builder name: ${builderName}`);
}
}
}
Loading

0 comments on commit 9a29e65

Please sign in to comment.