idz: Refactor repo interface/impl boundary

This commit is contained in:
Tau
2019-11-06 17:28:30 -05:00
parent ef50699295
commit eeb14a6bea
46 changed files with 108 additions and 85 deletions
+2 -2
View File
@@ -4,10 +4,10 @@ import { JoinAutoTeamRequest } from "../request/joinAutoTeam";
import { LoadTeamRequest } from "../request/loadTeam";
import { JoinAutoTeamResponse } from "../response/joinAutoTeam";
import { LoadTeamResponse } from "../response/loadTeam";
import { World } from "../world";
import { Repositories } from "../repo";
export function _team(
w: World,
w: Repositories,
req: JoinAutoTeamRequest | LoadTeamRequest
): JoinAutoTeamResponse | LoadTeamResponse {
const bits = {
+2 -2
View File
@@ -1,9 +1,9 @@
import { CheckTeamNameRequest } from "../request/checkTeamName";
import { CheckTeamNameResponse } from "../response/checkTeamName";
import { World } from "../world";
import { Repositories } from "../repo";
export function checkTeamName(
w: World,
w: Repositories,
req: CheckTeamNameRequest
): CheckTeamNameResponse {
return {
+2 -2
View File
@@ -7,10 +7,10 @@ import { Team } from "../model/team";
import { Unlocks } from "../model/unlocks";
import { CreateProfileRequest } from "../request/createProfile";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export async function createProfile(
w: World,
w: Repositories,
req: CreateProfileRequest
): Promise<GenericResponse> {
const profileId = await w.profile().generateId();
+2 -2
View File
@@ -2,10 +2,10 @@ import { Id } from "../model/base";
import { Team } from "../model/team";
import { CreateTeamRequest } from "../request/createTeam";
import { CreateTeamResponse } from "../response/createTeam";
import { World } from "../world";
import { Repositories } from "../repo";
export function createTeam(
w: World,
w: Repositories,
req: CreateTeamRequest
): CreateTeamResponse {
return {
+2 -2
View File
@@ -1,9 +1,9 @@
import { DiscoverProfileRequest } from "../request/discoverProfile";
import { DiscoverProfileResponse } from "../response/discoverProfile";
import { World } from "../world";
import { Repositories } from "../repo";
export async function discoverProfile(
w: World,
w: Repositories,
req: DiscoverProfileRequest
): Promise<DiscoverProfileResponse> {
return {
+5 -2
View File
@@ -35,9 +35,12 @@ import { updateUiReport } from "./updateUiReport";
import { updateUserLog } from "./updateUserLog";
import { Request } from "../request";
import { Response } from "../response";
import { World } from "../world";
import { Repositories } from "../repo";
export async function dispatch(w: World, req: Request): Promise<Response> {
export async function dispatch(
w: Repositories,
req: Request
): Promise<Response> {
switch (req.type) {
case "check_team_name_req":
return checkTeamName(w, req);
+5 -2
View File
@@ -1,8 +1,11 @@
import { Load2on2Request } from "../request/load2on2";
import { Load2on2Response } from "../response/load2on2";
import { World } from "../world";
import { Repositories } from "../repo";
export function load2on2(w: World, req: Load2on2Request): Load2on2Response {
export function load2on2(
w: Repositories,
req: Load2on2Request
): Load2on2Response {
return {
type: "load_2on2_res",
};
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadConfigRequest } from "../request/loadConfig";
import { LoadConfigResponse } from "../response/loadConfig";
import { World } from "../world";
import { Repositories } from "../repo";
export function loadConfig(
w: World,
w: Repositories,
req: LoadConfigRequest
): LoadConfigResponse {
return {
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadConfigRequest2 } from "../request/loadConfig2";
import { LoadConfigResponse2 } from "../response/loadConfig2";
import { World } from "../world";
import { Repositories } from "../repo";
export function loadConfig2(
w: World,
w: Repositories,
req: LoadConfigRequest2
): LoadConfigResponse2 {
return {
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadGarageRequest } from "../request/loadGarage";
import { LoadGarageResponse } from "../response/loadGarage";
import { World } from "../world";
import { Repositories } from "../repo";
export async function loadGarage(
w: World,
w: Repositories,
req: LoadGarageRequest
): Promise<LoadGarageResponse> {
return {
+2 -2
View File
@@ -1,10 +1,10 @@
import { LoadGeneralRewardRequest } from "../request/loadGeneralReward";
import { GenericResponse } from "../response/generic";
import { LoadGeneralRewardResponse } from "../response/loadGeneralReward";
import { World } from "../world";
import { Repositories } from "../repo";
export function loadGeneralReward(
w: World,
w: Repositories,
req: LoadGeneralRewardRequest
): LoadGeneralRewardResponse | GenericResponse {
// A non-generic response is also accepted, but why bother
+5 -2
View File
@@ -1,7 +1,10 @@
import { LoadGhostRequest } from "../request/loadGhost";
import { LoadGhostResponse } from "../response/loadGhost";
import { World } from "../world";
import { Repositories } from "../repo";
export function loadGhost(w: World, req: LoadGhostRequest): LoadGhostResponse {
export function loadGhost(
w: Repositories,
req: LoadGhostRequest
): LoadGhostResponse {
return { type: "load_ghost_res" };
}
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadProfileRequest } from "../request/loadProfile";
import { LoadProfileResponse2 } from "../response/loadProfile2";
import { World } from "../world";
import { Repositories } from "../repo";
export async function loadProfile(
w: World,
w: Repositories,
req: LoadProfileRequest
): Promise<LoadProfileResponse2> {
// Promise.all would be messy here, who cares anyway this isn't supposed to
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadRewardTableRequest } from "../request/loadRewardTable";
import { LoadRewardTableResponse } from "../response/loadRewardTable";
import { World } from "../world";
import { Repositories } from "../repo";
export function loadReward(
w: World,
w: Repositories,
req: LoadRewardTableRequest
): LoadRewardTableResponse {
return {
+2 -2
View File
@@ -1,10 +1,10 @@
import { LoadServerListRequest } from "../request/loadServerList";
import { LoadServerListResponse } from "../response/loadServerList";
import { World } from "../world";
import { Repositories } from "../repo";
import { hostname } from "../../hostname";
export function loadServerList(
w: World,
w: Repositories,
req: LoadServerListRequest
): LoadServerListResponse {
const myHost = hostname();
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadStockerRequest } from "../request/loadStocker";
import { LoadStockerResponse } from "../response/loadStocker";
import { World } from "../world";
import { Repositories } from "../repo";
export async function loadStocker(
w: World,
w: Repositories,
req: LoadStockerRequest
): Promise<LoadStockerResponse> {
const backgrounds = await w.backgrounds().loadAll(req.profileId);
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadTeamRankingRequest } from "../request/loadTeamRanking";
import { LoadTeamRankingResponse } from "../response/loadTeamRanking";
import { World } from "../world";
import { Repositories } from "../repo";
export function loadTeamRanking(
w: World,
w: Repositories,
req: LoadTeamRankingRequest
): LoadTeamRankingResponse {
return {
+2 -2
View File
@@ -1,9 +1,9 @@
import { LoadTopTenRequest } from "../request/loadTopTen";
import { LoadTopTenResponse } from "../response/loadTopTen";
import { World } from "../world";
import { Repositories } from "../repo";
export function loadTopTen(
w: World,
w: Repositories,
req: LoadTopTenRequest
): LoadTopTenResponse {
return {
+5 -2
View File
@@ -1,7 +1,10 @@
import { LockGarageRequest } from "../request/lockGarage";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export function lockGarage(w: World, req: LockGarageRequest): GenericResponse {
export function lockGarage(
w: Repositories,
req: LockGarageRequest
): GenericResponse {
return { type: "generic_res" };
}
+2 -2
View File
@@ -1,9 +1,9 @@
import { LockAccountRequest } from "../request/lockProfile";
import { LockProfileResponse } from "../response/lockProfile";
import { World } from "../world";
import { Repositories } from "../repo";
export function lockProfile(
w: World,
w: Repositories,
req: LockAccountRequest
): LockProfileResponse {
return {
+2 -2
View File
@@ -1,7 +1,7 @@
import { Message00AD } from "../request/msg00AD";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export function msg00AD(w: World, req: Message00AD): GenericResponse {
export function msg00AD(w: Repositories, req: Message00AD): GenericResponse {
return { type: "generic_res" };
}
+2 -2
View File
@@ -1,10 +1,10 @@
import { SaveExpeditionRequest } from "../request/saveExpedition";
import { GenericResponse } from "../response/generic";
import { SaveExpeditionResponse } from "../response/saveExpedition";
import { World } from "../world";
import { Repositories } from "../repo";
export function saveExpedition(
w: World,
w: Repositories,
req: SaveExpeditionRequest
): GenericResponse | SaveExpeditionResponse {
if (req.field_0004 === 0) {
+2 -2
View File
@@ -1,9 +1,9 @@
import { SaveGarageRequest } from "../request/saveGarage";
import { SaveGarageResponse } from "../response/saveGarage";
import { World } from "../world";
import { Repositories } from "../repo";
export function saveGarage(
w: World,
w: Repositories,
req: SaveGarageRequest
): SaveGarageResponse {
return {
+2 -2
View File
@@ -1,9 +1,9 @@
import { SaveNewCarRequest } from "../request/saveNewCar";
import { SaveNewCarResponse } from "../response/saveNewCar";
import { World } from "../world";
import { Repositories } from "../repo";
export async function saveNewCar(
w: World,
w: Repositories,
req: SaveNewCarRequest
): Promise<SaveNewCarResponse> {
await w.car().saveCar(req.profileId, req.car);
+2 -2
View File
@@ -1,9 +1,9 @@
import { SaveProfileRequest } from "../request/saveProfile";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export async function saveProfile(
w: World,
w: Repositories,
req: SaveProfileRequest
): Promise<GenericResponse> {
const profile = await w.profile().load(req.profileId);
+2 -2
View File
@@ -1,9 +1,9 @@
import { SaveSettingsRequest } from "../request/saveSettings";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export async function saveSettings(
w: World,
w: Repositories,
req: SaveSettingsRequest
): Promise<GenericResponse> {
await w.settings().save(req.profileId, req.settings);
+2 -2
View File
@@ -1,9 +1,9 @@
import { SaveStockerRequest } from "../request/saveStocker";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export async function saveStocker(
w: World,
w: Repositories,
req: SaveStockerRequest
): Promise<GenericResponse> {
await Promise.all([
+2 -2
View File
@@ -1,9 +1,9 @@
import { SaveTimeAttackRequest } from "../request/saveTimeAttack";
import { SaveTimeAttackResponse } from "../response/saveTimeAttack";
import { World } from "../world";
import { Repositories } from "../repo";
export async function saveTimeAttack(
w: World,
w: Repositories,
req: SaveTimeAttackRequest
): Promise<SaveTimeAttackResponse> {
if (req.payload.totalMsec > 0) {
+5 -2
View File
@@ -1,8 +1,11 @@
import { SaveTopicRequest } from "../request/saveTopic";
import { SaveTopicResponse } from "../response/saveTopic";
import { World } from "../world";
import { Repositories } from "../repo";
export function saveTopic(w: World, req: SaveTopicRequest): SaveTopicResponse {
export function saveTopic(
w: Repositories,
req: SaveTopicRequest
): SaveTopicResponse {
return {
type: "save_topic_res",
};
+2 -2
View File
@@ -1,9 +1,9 @@
import { UnlockProfileRequest } from "../request/unlockProfile";
import { UnlockProfileResponse } from "../response/unlockProfile";
import { World } from "../world";
import { Repositories } from "../repo";
export function unlockProfile(
w: World,
w: Repositories,
req: UnlockProfileRequest
): UnlockProfileResponse {
return {
@@ -1,9 +1,9 @@
import { UpdateProvisionalStoreRankRequest } from "../request/updateProvisionalStoreRank";
import { UpdateProvisionalStoreRankResponse } from "../response/updateProvisionalStoreRank";
import { World } from "../world";
import { Repositories } from "../repo";
export function updateProvisionalStoreRank(
w: World,
w: Repositories,
req: UpdateProvisionalStoreRankRequest
): UpdateProvisionalStoreRankResponse {
return {
+2 -2
View File
@@ -1,9 +1,9 @@
import { UpdateStoryClearNumRequest } from "../request/updateStoryClearNum";
import { UpdateStoryClearNumResponse } from "../response/updateStoryClearNum";
import { World } from "../world";
import { Repositories } from "../repo";
export function updateStoryClearNum(
w: World,
w: Repositories,
req: UpdateStoryClearNumRequest
): UpdateStoryClearNumResponse {
return {
+2 -2
View File
@@ -1,9 +1,9 @@
import { UpdateTeamPointsRequest } from "../request/updateTeamPoints";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export function updateTeamPoints(
w: World,
w: Repositories,
req: UpdateTeamPointsRequest
): GenericResponse {
return { type: "generic_res" };
+2 -2
View File
@@ -1,9 +1,9 @@
import { UpdateUiReportRequest } from "../request/updateUiReport";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export function updateUiReport(
w: World,
w: Repositories,
req: UpdateUiReportRequest
): GenericResponse {
return { type: "generic_res" };
+2 -2
View File
@@ -1,9 +1,9 @@
import { UpdateUserLogRequest } from "../request/updateUserLog";
import { GenericResponse } from "../response/generic";
import { World } from "../world";
import { Repositories } from "../repo";
export function updateUserLog(
w: World,
w: Repositories,
req: UpdateUserLogRequest
): GenericResponse {
return { type: "generic_res" };