diff --git a/client/src/app/pages/dashboard/users/UserIntegrationsPage.tsx b/client/src/app/pages/dashboard/users/UserIntegrationsPage.tsx index 1e3b84bf0..7701f2575 100644 --- a/client/src/app/pages/dashboard/users/UserIntegrationsPage.tsx +++ b/client/src/app/pages/dashboard/users/UserIntegrationsPage.tsx @@ -662,8 +662,11 @@ function ServicesPage({ reqUser }: { reqUser: UserDocument }) { - - + + + + + @@ -951,7 +954,7 @@ function APIKeyRow({ ); } -function CGIntegrationInfo({ cgType, userID }: { cgType: "dev" | "prod"; userID: integer }) { +function CGIntegrationInfo({ cgType, userID }: { cgType: "dev" | "gan" | "nag"; userID: integer }) { const [reload, shouldReloadCardInfo] = useReducer((x) => x + 1, 0); const { data, error } = useApiQuery( diff --git a/client/src/app/routes/ImportRoutes.tsx b/client/src/app/routes/ImportRoutes.tsx index 6ae4a2c40..63229bf19 100644 --- a/client/src/app/routes/ImportRoutes.tsx +++ b/client/src/app/routes/ImportRoutes.tsx @@ -177,14 +177,24 @@ export default function ImportRoutes() { - - + + - - + + - - + + + + + + + + + + + + diff --git a/client/src/components/imports/CGIntegrationPage.tsx b/client/src/components/imports/CGIntegrationPage.tsx index fcc07c900..b1948a958 100644 --- a/client/src/components/imports/CGIntegrationPage.tsx +++ b/client/src/components/imports/CGIntegrationPage.tsx @@ -16,13 +16,13 @@ import Icon from "components/util/Icon"; import ImportStateRenderer from "./ImportStateRenderer"; interface Props { - cgType: "dev" | "prod"; + cgType: "dev" | "gan" | "nag"; game: "sdvx" | "popn" | "museca"; } export default function CGIntegrationPage({ cgType, game }: Props) { const gameConfig = GetGameConfig(game); - const cgName = cgType === "dev" ? "CG Dev" : "CG"; + const cgName = cgType === "dev" ? "CG Dev" : `CG ${cgType.toUpperCase()}`; const [reload, shouldReloadCardInfo] = useReducer((x) => x + 1, 0); const [showEdit, setShowEdit] = useState(false); @@ -105,7 +105,7 @@ function CGImporter({ setShowEdit: SetState; }) { const importType: APIImportTypes = `api/cg-${cgType}-${game}`; - const cgName = cgType === "dev" ? "CG Dev" : "CG"; + const cgName = cgType === "dev" ? "CG Dev" : `CG ${cgType.toUpperCase()}`; const { importState, runImport } = useImport("/import/from-api", { method: "POST", diff --git a/common/src/constants/import-types.ts b/common/src/constants/import-types.ts index 0f2e734df..6b1de87b2 100644 --- a/common/src/constants/import-types.ts +++ b/common/src/constants/import-types.ts @@ -38,9 +38,12 @@ const API_IMPORT_TYPES: Record = { "api/cg-dev-museca": true, "api/cg-dev-popn": true, "api/cg-dev-sdvx": true, - "api/cg-prod-museca": true, - "api/cg-prod-popn": true, - "api/cg-prod-sdvx": true, + "api/cg-nag-museca": true, + "api/cg-nag-popn": true, + "api/cg-nag-sdvx": true, + "api/cg-gan-museca": true, + "api/cg-gan-popn": true, + "api/cg-gan-sdvx": true, }; export const fileImportTypes: Array = Object.keys( diff --git a/common/src/types/documents.ts b/common/src/types/documents.ts index 8d82d27a6..11836a438 100644 --- a/common/src/types/documents.ts +++ b/common/src/types/documents.ts @@ -566,7 +566,7 @@ export interface KaiAuthDocument { export interface CGCardInfo { userID: integer; - service: "dev" | "prod"; + service: "dev" | "gan" | "nag"; cardID: string; // are we gonna do maths on it? no. it's a string. don't bother me. diff --git a/common/src/types/import-types.ts b/common/src/types/import-types.ts index c24e2007c..046879d9d 100644 --- a/common/src/types/import-types.ts +++ b/common/src/types/import-types.ts @@ -18,7 +18,7 @@ export type APIImportTypes = // cg has dev and prod supported // with four games. // this typescript feature for stringliteral expansion is kinda neat. - | `api/cg-${"dev" | "prod"}-${"museca" | "popn" | "sdvx"}`; + | `api/cg-${"dev" | "gan" | "nag"}-${"museca" | "popn" | "sdvx"}`; export type IRImportTypes = | "ir/barbatos" diff --git a/server/src/external/mongo/schemas.ts b/server/src/external/mongo/schemas.ts index 9f84fda5d..0091b0c41 100644 --- a/server/src/external/mongo/schemas.ts +++ b/server/src/external/mongo/schemas.ts @@ -41,7 +41,7 @@ export const DatabaseSchemas: Record = { }), "cg-card-info": prSchemaify({ userID: p.isPositiveNonZeroInteger, - service: p.isIn("dev", "prod"), + service: p.isIn("dev", "gan", "nag"), cardID: "string", pin: "string", }), diff --git a/server/src/lib/score-import/import-types/common/api-cg/parsers.ts b/server/src/lib/score-import/import-types/common/api-cg/parsers.ts index 46dc496aa..5849991cb 100644 --- a/server/src/lib/score-import/import-types/common/api-cg/parsers.ts +++ b/server/src/lib/score-import/import-types/common/api-cg/parsers.ts @@ -144,7 +144,12 @@ export const ParseCGDevSDVX = CreateCGParser("sdvx", "dev"); export const ParseCGDevJubeat = CreateCGParser("jb", "dev"); export const ParseCGDevPopn = CreateCGParser("popn", "dev"); -export const ParseCGProdMuseca = CreateCGParser("msc", "prod"); -export const ParseCGProdSDVX = CreateCGParser("sdvx", "prod"); -export const ParseCGProdJubeat = CreateCGParser("jb", "prod"); -export const ParseCGProdPopn = CreateCGParser("popn", "prod"); +export const ParseCGGanMuseca = CreateCGParser("msc", "gan"); +export const ParseCGGanSDVX = CreateCGParser("sdvx", "gan"); +export const ParseCGGanJubeat = CreateCGParser("jb", "gan"); +export const ParseCGGanPopn = CreateCGParser("popn", "gan"); + +export const ParseCGNagMuseca = CreateCGParser("msc", "nag"); +export const ParseCGNagSDVX = CreateCGParser("sdvx", "nag"); +export const ParseCGNagJubeat = CreateCGParser("jb", "nag"); +export const ParseCGNagPopn = CreateCGParser("popn", "nag"); diff --git a/server/src/lib/score-import/import-types/common/api-cg/traverse-api.ts b/server/src/lib/score-import/import-types/common/api-cg/traverse-api.ts index 13f9c826c..81494f29d 100644 --- a/server/src/lib/score-import/import-types/common/api-cg/traverse-api.ts +++ b/server/src/lib/score-import/import-types/common/api-cg/traverse-api.ts @@ -73,27 +73,33 @@ export async function FetchCGScores( } function GetCGConf(service: CGServices) { + let conf; + switch (service) { case "dev": { - if (!ServerConfig.CG_DEV_CONFIG) { - throw new Error( - `No CG_DEV_CONFIG is available, yet a request to cg-dev was attempted?` - ); - } - - return ServerConfig.CG_DEV_CONFIG; + conf = ServerConfig.CG_DEV_CONFIG; + break; } - case "prod": { - if (!ServerConfig.CG_PROD_CONFIG) { - throw new Error( - `No CG_PROD_CONFIG is available, yet a request to cg-prod was attempted?` - ); - } + case "nag": { + conf = ServerConfig.CG_NAG_CONFIG; + break; + } - return ServerConfig.CG_PROD_CONFIG; + case "gan": { + conf = ServerConfig.CG_GAN_CONFIG; + break; } } + + if (!conf) { + throw new ScoreImportFatalError( + 500, + `Tried to get ${service} CG conf, yet was not defined?` + ); + } + + return conf; } function GetCGUrl(service: CGServices, cardInfo: CGCardInfo, game: CGSupportedGames) { diff --git a/server/src/lib/score-import/import-types/common/api-cg/types.ts b/server/src/lib/score-import/import-types/common/api-cg/types.ts index 79f45db31..5958fd577 100644 --- a/server/src/lib/score-import/import-types/common/api-cg/types.ts +++ b/server/src/lib/score-import/import-types/common/api-cg/types.ts @@ -6,7 +6,7 @@ export type CGSupportedGames = | "popn" | "sdvx"; -export type CGServices = "dev" | "prod"; +export type CGServices = "dev" | "gan" | "nag"; export interface CGScoresResponse { success: true; @@ -84,6 +84,6 @@ export interface CGJubeatScore { } export interface CGContext { - service: "dev" | "prod"; + service: CGServices; userID: integer; } diff --git a/server/src/lib/score-import/import-types/common/types.ts b/server/src/lib/score-import/import-types/common/types.ts index 308c4095d..2d76eb4e0 100644 --- a/server/src/lib/score-import/import-types/common/types.ts +++ b/server/src/lib/score-import/import-types/common/types.ts @@ -65,9 +65,13 @@ export interface ImportTypeDataMap { // "api/cg-dev-jubeat": CGJubeatScore; // "api/cg-prod-jubeat": CGJubeatScore; - "api/cg-prod-sdvx": CGSDVXScore; - "api/cg-prod-museca": CGMusecaScore; - "api/cg-prod-popn": CGPopnScore; + "api/cg-nag-sdvx": CGSDVXScore; + "api/cg-nag-museca": CGMusecaScore; + "api/cg-nag-popn": CGPopnScore; + + "api/cg-gan-sdvx": CGSDVXScore; + "api/cg-gan-museca": CGMusecaScore; + "api/cg-gan-popn": CGPopnScore; } export interface ImportTypeContextMap { @@ -100,10 +104,14 @@ export interface ImportTypeContextMap { "api/cg-dev-sdvx": CGContext; "api/cg-dev-museca": CGContext; "api/cg-dev-popn": CGContext; - "api/cg-prod-jubeat": CGContext; - "api/cg-prod-sdvx": CGContext; - "api/cg-prod-museca": CGContext; - "api/cg-prod-popn": CGContext; + "api/cg-nag-jubeat": CGContext; + "api/cg-nag-sdvx": CGContext; + "api/cg-nag-museca": CGContext; + "api/cg-nag-popn": CGContext; + "api/cg-gan-jubeat": CGContext; + "api/cg-gan-sdvx": CGContext; + "api/cg-gan-museca": CGContext; + "api/cg-gan-popn": CGContext; } export interface OrphanScoreDocument { diff --git a/server/src/lib/score-import/import-types/converters.ts b/server/src/lib/score-import/import-types/converters.ts index 149f7c68c..e46c38076 100644 --- a/server/src/lib/score-import/import-types/converters.ts +++ b/server/src/lib/score-import/import-types/converters.ts @@ -58,10 +58,10 @@ export const Converters: ConverterMap = { "api/cg-dev-sdvx": ConverterAPICGSDVX, "api/cg-dev-museca": ConverterAPICGMuseca, "api/cg-dev-popn": ConverterAPICGPopn, - "api/cg-prod-sdvx": ConverterAPICGSDVX, - "api/cg-prod-museca": ConverterAPICGMuseca, - "api/cg-prod-popn": ConverterAPICGPopn, - - // "api/cg-dev-jubeat": ConverterAPICGJubeat, - // "api/cg-prod-jubeat": ConverterAPICGJubeat, + "api/cg-nag-sdvx": ConverterAPICGSDVX, + "api/cg-nag-museca": ConverterAPICGMuseca, + "api/cg-nag-popn": ConverterAPICGPopn, + "api/cg-gan-sdvx": ConverterAPICGSDVX, + "api/cg-gan-museca": ConverterAPICGMuseca, + "api/cg-gan-popn": ConverterAPICGPopn, }; diff --git a/server/src/lib/score-import/import-types/parsers.ts b/server/src/lib/score-import/import-types/parsers.ts index a7e13b7de..8e6dce78c 100644 --- a/server/src/lib/score-import/import-types/parsers.ts +++ b/server/src/lib/score-import/import-types/parsers.ts @@ -4,14 +4,15 @@ import { ParseFloIIDX } from "./api/flo-iidx/parser"; import { ParseFloSDVX } from "./api/flo-sdvx/parser"; import { ParseMinSDVX } from "./api/min-sdvx/parser"; import { - ParseCGDevJubeat, ParseCGDevMuseca, ParseCGDevPopn, ParseCGDevSDVX, - ParseCGProdJubeat, - ParseCGProdMuseca, - ParseCGProdPopn, - ParseCGProdSDVX, + ParseCGGanMuseca, + ParseCGGanPopn, + ParseCGGanSDVX, + ParseCGNagMuseca, + ParseCGNagPopn, + ParseCGNagSDVX, } from "./common/api-cg/parsers"; import ParseBatchManual from "./file/batch-manual/parser"; import ParseEamusementIIDXCSV from "./file/eamusement-iidx-csv/parser"; @@ -20,8 +21,8 @@ import { ParseMerIIDX } from "./file/mer-iidx/parser"; import ParsePLIIIDXCSV from "./file/pli-iidx-csv/parser"; import { ParseSolidStateXML } from "./file/solid-state-squad/parser"; import { - ParseMyPageScraperRecordsCSV, ParseMyPageScraperPlayerCSV, + ParseMyPageScraperRecordsCSV, } from "./file/wacca-mypage-scraper/parser"; import { ParseBarbatosSingle } from "./ir/barbatos/parser"; import { ParseBeatorajaSingle } from "./ir/beatoraja/parser"; @@ -52,14 +53,18 @@ export const Parsers = { "api/cg-dev-sdvx": ParseCGDevSDVX, "api/cg-dev-popn": ParseCGDevPopn, "api/cg-dev-museca": ParseCGDevMuseca, - "api/cg-prod-sdvx": ParseCGProdSDVX, // temporarily disabled as no musicRate is provided. // "api/cg-dev-jubeat": ParseCGDevJubeat, // "api/cg-prod-jubeat": ParseCGProdJubeat, - "api/cg-prod-popn": ParseCGProdPopn, - "api/cg-prod-museca": ParseCGProdMuseca, + "api/cg-nag-sdvx": ParseCGNagSDVX, + "api/cg-nag-popn": ParseCGNagPopn, + "api/cg-nag-museca": ParseCGNagMuseca, + + "api/cg-gan-sdvx": ParseCGGanSDVX, + "api/cg-gan-popn": ParseCGGanPopn, + "api/cg-gan-museca": ParseCGGanMuseca, "ir/barbatos": ParseBarbatosSingle, "ir/beatoraja": ParseBeatorajaSingle, diff --git a/server/src/lib/setup/config.ts b/server/src/lib/setup/config.ts index b91e0b5b9..cbb8cee0a 100644 --- a/server/src/lib/setup/config.ts +++ b/server/src/lib/setup/config.ts @@ -67,7 +67,8 @@ export interface TachiServerConfig { ARC_API_URL?: string; CG_DEV_CONFIG?: CGConfig; - CG_PROD_CONFIG?: CGConfig; + CG_NAG_CONFIG?: CGConfig; + CG_GAN_CONFIG?: CGConfig; FLO_OAUTH2_INFO?: OAuth2Info; EAG_OAUTH2_INFO?: OAuth2Info; @@ -162,7 +163,8 @@ const err = p(config, { ARC_API_URL: p.optional(isValidURL), CG_DEV_CONFIG: isValidCGConfig, - CG_PROD_CONFIG: isValidCGConfig, + CG_NAG_CONFIG: isValidCGConfig, + CG_GAN_CONFIG: isValidCGConfig, FLO_OAUTH2_INFO: isValidOauth2, EAG_OAUTH2_INFO: isValidOauth2, diff --git a/server/src/server/router/api/v1/users/_userID/integrations/cg/_cgType/router.ts b/server/src/server/router/api/v1/users/_userID/integrations/cg/_cgType/router.ts index e3fd32be3..835e82460 100644 --- a/server/src/server/router/api/v1/users/_userID/integrations/cg/_cgType/router.ts +++ b/server/src/server/router/api/v1/users/_userID/integrations/cg/_cgType/router.ts @@ -5,12 +5,13 @@ import { p } from "prudence"; import prValidate from "server/middleware/prudence-validate"; import { GetTachiData } from "utils/req-tachi-data"; import type { RequestHandler } from "express-serve-static-core"; +import type { CGServices } from "lib/score-import/import-types/common/api-cg/types"; import type { CGCardInfo } from "tachi-common"; const router: Router = Router({ mergeParams: true }); const ValidateCGType: RequestHandler = (req, res, next) => { - if (req.params.cgType === "dev" || req.params.cgType === "prod") { + if (req.params.cgType === "dev" || req.params.cgType === "nag" || req.params.cgType === "gan") { next(); return; } @@ -28,7 +29,7 @@ const ValidateCGType: RequestHandler = (req, res, next) => { */ router.get("/", ValidateCGType, RequireSelfRequestFromUser, async (req, res) => { const user = GetTachiData(req, "requestedUser"); - const cgType = req.params.cgType as "dev" | "prod"; + const cgType = req.params.cgType as CGServices; const cardInfo = await db["cg-card-info"].findOne({ userID: user.id, @@ -71,7 +72,7 @@ router.put( ), async (req, res) => { const user = GetTachiData(req, "requestedUser"); - const cgType = req.params.cgType as "dev" | "prod"; + const cgType = req.params.cgType as CGServices; const { cardID, pin } = req.safeBody as { cardID: string; @@ -112,7 +113,7 @@ router.put( */ router.delete("/", ValidateCGType, RequireSelfRequestFromUser, async (req, res) => { const user = GetTachiData(req, "requestedUser"); - const cgType = req.params.cgType as "dev" | "prod"; + const cgType = req.params.cgType as CGServices; await db["cg-card-info"].remove({ userID: user.id, diff --git a/server/src/test-utils/hack-setup.js b/server/src/test-utils/hack-setup.js index 97c5169cc..c530fd0c7 100644 --- a/server/src/test-utils/hack-setup.js +++ b/server/src/test-utils/hack-setup.js @@ -6,5 +6,7 @@ const path = require("path"); const assert = require("assert"); +console.log(`Hit HACK_SETUP.js @ ${Date.now()}.`); + assert(process.env.NODE_ENV === "test", "NODE_ENV WAS NOT TEST, BAILING"); execSync(`ts-node ${path.join(__dirname, "./setup.ts")}`, { stdio: "inherit" });