From 8d527af2e90604acfe295cd52efb082467162996 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sat, 30 Aug 2025 05:12:47 +0200 Subject: [PATCH 1/2] we should get a type error when attempting to access a removed option on config --- src/services/configService.ts | 8 ++------ src/services/configWatcherService.ts | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/services/configService.ts b/src/services/configService.ts index 97817f76..0d829b92 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -4,7 +4,7 @@ import { repoDir } from "../helpers/pathHelper.ts"; import { args } from "../helpers/commandLineArguments.ts"; import { Inbox } from "../models/inboxModel.ts"; -export interface IConfig extends IConfigRemovedOptions { +export interface IConfig { mongodbUrl: string; logger: { files: boolean; @@ -123,11 +123,7 @@ export const configRemovedOptionsKeys = [ "flawlessRelicsAlwaysGiveSilverReward", "radiantRelicsAlwaysGiveGoldReward", "disableDailyTribute" -] as const; - -type IConfigRemovedOptions = { - [K in (typeof configRemovedOptionsKeys)[number]]?: boolean; -}; +]; export const configPath = path.join(repoDir, args.configPath ?? "config.json"); diff --git a/src/services/configWatcherService.ts b/src/services/configWatcherService.ts index 1788d58a..d0f72981 100644 --- a/src/services/configWatcherService.ts +++ b/src/services/configWatcherService.ts @@ -1,6 +1,13 @@ import chokidar from "chokidar"; import { logger } from "../utils/logger.ts"; -import { config, configPath, configRemovedOptionsKeys, loadConfig, syncConfigWithDatabase } from "./configService.ts"; +import { + config, + configPath, + configRemovedOptionsKeys, + loadConfig, + syncConfigWithDatabase, + type IConfig +} from "./configService.ts"; import { saveConfig, shouldReloadConfig } from "./configWriterService.ts"; import { getWebPorts, startWebServer, stopWebServer } from "./webService.ts"; import { sendWsBroadcast } from "./wsService.ts"; @@ -35,9 +42,11 @@ chokidar.watch(configPath).on("change", () => { export const validateConfig = (): void => { let modified = false; for (const key of configRemovedOptionsKeys) { - if (config[key] !== undefined) { - logger.debug(`Spotted removed option ${key} with value ${config[key]} in config.json.`); - delete config[key]; + if (config[key as keyof IConfig] !== undefined) { + logger.debug( + `Spotted removed option ${key} with value ${String(config[key as keyof IConfig])} in config.json.` + ); + delete config[key as keyof IConfig]; modified = true; } } -- 2.47.2 From 68c16b98519dea2a027b631ad9c7cedcb13c330e Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Sat, 30 Aug 2025 05:21:24 +0200 Subject: [PATCH 2/2] chore: move unlockAllSimarisResearchEntries to a per-account button --- src/controllers/api/inventoryController.ts | 13 ------------ ...lockAllSimarisResearchEntriesController.ts | 20 +++++++++++++++++++ src/routes/custom.ts | 2 ++ src/services/configService.ts | 2 +- static/webui/index.html | 9 +++------ static/webui/script.js | 10 ++++++++-- 6 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 src/controllers/custom/unlockAllSimarisResearchEntriesController.ts diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index 100f0a1a..13bbd21a 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -486,19 +486,6 @@ export const getInventoryResponse = async ( } } - if (config.unlockAllSimarisResearchEntries) { - inventoryResponse.LibraryPersonalTarget = undefined; - inventoryResponse.LibraryPersonalProgress = [ - "/Lotus/Types/Game/Library/Targets/Research1Target", - "/Lotus/Types/Game/Library/Targets/Research2Target", - "/Lotus/Types/Game/Library/Targets/Research3Target", - "/Lotus/Types/Game/Library/Targets/Research4Target", - "/Lotus/Types/Game/Library/Targets/Research5Target", - "/Lotus/Types/Game/Library/Targets/Research6Target", - "/Lotus/Types/Game/Library/Targets/Research7Target" - ].map(type => ({ TargetType: type, Scans: 10, Completed: true })); - } - return inventoryResponse; }; diff --git a/src/controllers/custom/unlockAllSimarisResearchEntriesController.ts b/src/controllers/custom/unlockAllSimarisResearchEntriesController.ts new file mode 100644 index 00000000..fae3c55d --- /dev/null +++ b/src/controllers/custom/unlockAllSimarisResearchEntriesController.ts @@ -0,0 +1,20 @@ +import type { RequestHandler } from "express"; +import { getAccountIdForRequest } from "../../services/loginService.ts"; +import { getInventory } from "../../services/inventoryService.ts"; + +export const unlockAllSimarisResearchEntriesController: RequestHandler = async (req, res) => { + const accountId = await getAccountIdForRequest(req); + const inventory = await getInventory(accountId, "LibraryPersonalTarget LibraryPersonalProgress"); + inventory.LibraryPersonalTarget = undefined; + inventory.LibraryPersonalProgress = [ + "/Lotus/Types/Game/Library/Targets/Research1Target", + "/Lotus/Types/Game/Library/Targets/Research2Target", + "/Lotus/Types/Game/Library/Targets/Research3Target", + "/Lotus/Types/Game/Library/Targets/Research4Target", + "/Lotus/Types/Game/Library/Targets/Research5Target", + "/Lotus/Types/Game/Library/Targets/Research6Target", + "/Lotus/Types/Game/Library/Targets/Research7Target" + ].map(type => ({ TargetType: type, Scans: 10, Completed: true })); + await inventory.save(); + res.end(); +}; diff --git a/src/routes/custom.ts b/src/routes/custom.ts index 6f10f563..8f272e33 100644 --- a/src/routes/custom.ts +++ b/src/routes/custom.ts @@ -15,6 +15,7 @@ import { webuiFileChangeDetectedController } from "../controllers/custom/webuiFi import { completeAllMissionsController } from "../controllers/custom/completeAllMissionsController.ts"; import { addMissingHelminthBlueprintsController } from "../controllers/custom/addMissingHelminthBlueprintsController.ts"; import { unlockAllProfitTakerStagesController } from "../controllers/custom/unlockAllProfitTakerStagesController.ts"; +import { unlockAllSimarisResearchEntriesController } from "../controllers/custom/unlockAllSimarisResearchEntriesController.ts"; import { abilityOverrideController } from "../controllers/custom/abilityOverrideController.ts"; import { createAccountController } from "../controllers/custom/createAccountController.ts"; @@ -50,6 +51,7 @@ customRouter.get("/webuiFileChangeDetected", webuiFileChangeDetectedController); customRouter.get("/completeAllMissions", completeAllMissionsController); customRouter.get("/addMissingHelminthBlueprints", addMissingHelminthBlueprintsController); customRouter.get("/unlockAllProfitTakerStages", unlockAllProfitTakerStagesController); +customRouter.get("/unlockAllSimarisResearchEntries", unlockAllSimarisResearchEntriesController); customRouter.post("/abilityOverride", abilityOverrideController); customRouter.post("/createAccount", createAccountController); diff --git a/src/services/configService.ts b/src/services/configService.ts index 0d829b92..28ab1c3c 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -33,7 +33,6 @@ export interface IConfig { noDojoResearchCosts?: boolean; noDojoResearchTime?: boolean; fastClanAscension?: boolean; - unlockAllSimarisResearchEntries?: boolean; spoofMasteryRank?: number; relicRewardItemCountMultiplier?: number; nightwaveStandingMultiplier?: number; @@ -105,6 +104,7 @@ export const configRemovedOptionsKeys = [ "unlockExilusEverywhere", "unlockArcanesEverywhere", "unlockAllProfitTakerStages", + "unlockAllSimarisResearchEntries", "noDailyStandingLimits", "noDailyFocusLimit", "noArgonCrystalDecay", diff --git a/static/webui/index.html b/static/webui/index.html index b558edf7..28577b95 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -775,10 +775,6 @@ -