diff --git a/common/src/config/config-utils.ts b/common/src/config/config-utils.ts index 232273d98..68e96229c 100644 --- a/common/src/config/config-utils.ts +++ b/common/src/config/config-utils.ts @@ -33,13 +33,15 @@ export function ClassValue( return { id, display, hoverText }; } -export const zodTierlistData = z.nullable( - z.strictObject({ - value: z.number(), - text: z.string(), - individualDifference: z.boolean(), - }) -); +export const zodTierlistData = z + .nullable( + z.strictObject({ + value: z.number(), + text: z.string(), + individualDifference: z.boolean(), + }) + ) + .optional(); export const zodInt = z.number().int(); export const zodNonNegativeInt = z.number().int().nonnegative(); diff --git a/common/src/config/game-support/bms.ts b/common/src/config/game-support/bms.ts index 787db8447..cae94862f 100644 --- a/common/src/config/game-support/bms.ts +++ b/common/src/config/game-support/bms.ts @@ -247,9 +247,9 @@ export const BMS_7K_CONF = { hashMD5: z.string(), hashSHA256: z.string(), tableFolders: z.array(z.strictObject({ table: z.string(), level: z.string() })), - sglEC: z.number().nullable(), - sglHC: z.number().nullable(), - aiLevel: z.string().nullable(), + sglEC: z.number().nullable().optional(), + sglHC: z.number().nullable().optional(), + aiLevel: z.string().nullable().optional(), }), preferences: z.strictObject({ diff --git a/common/src/seeds/types.ts b/common/src/seeds/types.ts index bef469f4f..14089f128 100644 --- a/common/src/seeds/types.ts +++ b/common/src/seeds/types.ts @@ -44,14 +44,12 @@ const CURRENT_DATABASE_SEEDS: Record = { "tables.json": true, }; -for (const game of allSupportedGames) { - // @ts-expect-error define all games' seeds on the object. - CURRENT_DATABASE_SEEDS[`songs-${game}`] = true; +const moreOnes: Array = []; - // @ts-expect-error define all games' seeds on the object. - CURRENT_DATABASE_SEEDS[`charts-${game}`] = true; +for (const game of allSupportedGames) { + moreOnes.push(`songs-${game}`, `charts-${game}`); } -export const DatabaseSeedNames = Object.keys(CURRENT_DATABASE_SEEDS) as Array< +export const DatabaseSeedNames = [...Object.keys(CURRENT_DATABASE_SEEDS), ...moreOnes] as Array< keyof AllDatabaseSeeds >; diff --git a/database-seeds/scripts/test/collections.test.ts b/database-seeds/scripts/test/collections.test.ts index 8c4cdbd38..1ebf5fa06 100644 --- a/database-seeds/scripts/test/collections.test.ts +++ b/database-seeds/scripts/test/collections.test.ts @@ -1,9 +1,10 @@ import chalk from "chalk"; import fs from "fs"; import path from "path"; -import { SCHEMAS } from "tachi-common/lib/schemas"; import { ReadCollection } from "../util"; import { FormatFunctions } from "./test-utils"; +import { SCHEMAS } from "tachi-common/lib/schemas"; +import { Game } from "tachi-common"; function FormatPrError(err, foreword = "Error") { const receivedText = @@ -28,7 +29,7 @@ for (const collection of collections) { let fails = 0; const collectionName = `${collection}.json`; - const formatFn = FormatFunctions[collection]; + const formatFn = FormatFunctions[collection] ?? ((v) => JSON.stringify(v)); const data = ReadCollection(collectionName, true); @@ -48,7 +49,7 @@ for (const collection of collections) { for (const d of data) { // Will throw if formatFn is undefined -- that's a test failure in my book. - const pretty = formatFn(d, game); + const pretty = formatFn(d, game as Game); try { validator(d); diff --git a/database-seeds/scripts/test/id.test.ts b/database-seeds/scripts/test/id.test.ts index db16de997..898c6222c 100644 --- a/database-seeds/scripts/test/id.test.ts +++ b/database-seeds/scripts/test/id.test.ts @@ -1,12 +1,10 @@ import chalk from "chalk"; -import { Game, integer } from "tachi-common"; -import { allSupportedGames } from "tachi-common/config/static-config"; -import { SCHEMAS } from "tachi-common/lib/schemas"; -import { ReadCollection } from "../util"; +import { Game, allSupportedGames, integer } from "tachi-common"; import { FormatFunctions } from "./test-utils"; import get from "lodash.get"; import fjsh from "fast-json-stable-hash"; -import logger from "../logger"; +import { SCHEMAS } from "tachi-common/lib/schemas"; +import { ReadCollection } from "../util"; // Either it's a bare string or an array of strings for co-uniqueness. type DuplicateKeyDecl = string | string[]; @@ -88,7 +86,7 @@ for (const [collection, uniqueIDs] of Object.entries(UniqueKeys)) { console.log(`[VALIDATING DUPES] ${collection}`); const collectionName = `${collection}.json`; - const formatFn = FormatFunctions[collection]; + const formatFn = FormatFunctions[collection] ?? ((v) => JSON.stringify(v)); let success = 0; let fails = 0; @@ -111,7 +109,7 @@ for (const [collection, uniqueIDs] of Object.entries(UniqueKeys)) { const set = new Set(); for (const d of data) { - const pretty = formatFn(d, game); + const pretty = formatFn(d, game as Game); let value: Array>; diff --git a/database-seeds/scripts/test/match-type.test.ts b/database-seeds/scripts/test/match-type.test.ts index aa0fee46c..ea5e98a0a 100644 --- a/database-seeds/scripts/test/match-type.test.ts +++ b/database-seeds/scripts/test/match-type.test.ts @@ -8,8 +8,8 @@ import { MatchTypes, Playtype, SongDocument, + allSupportedGames, } from "tachi-common"; -import { allSupportedGames } from "tachi-common/config/static-config"; import { ReadCollection } from "../util"; // check that a given matchType works for a given game. diff --git a/database-seeds/scripts/test/references.test.ts b/database-seeds/scripts/test/references.test.ts index c529abfd1..1bc4c158d 100644 --- a/database-seeds/scripts/test/references.test.ts +++ b/database-seeds/scripts/test/references.test.ts @@ -2,8 +2,7 @@ // and no quest-goal desync, etc. import chalk from "chalk"; -import { Game } from "tachi-common"; -import { allSupportedGames } from "tachi-common/config/static-config"; +import { Game, allSupportedGames } from "tachi-common"; import { ReadCollection } from "../util"; import { FormatFunctions } from "./test-utils"; @@ -63,7 +62,7 @@ for (const refCheck of refChecks) { }) ); - const formatFn = FormatFunctions[refCheck.base]; + const formatFn = FormatFunctions[refCheck.base] ?? ((v) => JSON.stringify(v)); for (const data of baseData) { const keys: Array = []; diff --git a/database-seeds/scripts/test/table-default.test.ts b/database-seeds/scripts/test/table-default.test.ts index cc3a9026c..53686658b 100644 --- a/database-seeds/scripts/test/table-default.test.ts +++ b/database-seeds/scripts/test/table-default.test.ts @@ -1,6 +1,5 @@ import chalk from "chalk"; -import { FormatGame, TableDocument } from "tachi-common"; -import { allGPTString } from "tachi-common/config/static-config"; +import { FormatGame, TableDocument, allGPTStrings } from "tachi-common"; import { ReadCollection } from "../util"; const gptStringMap = {}; @@ -38,7 +37,7 @@ for (const t of tables) { } } -for (const gptString of allGPTString) { +for (const gptString of allGPTStrings) { if (!gptStringMap[gptString]) { console.log(chalk.red(`[TABLE-DEFAULT] There is no default table for ${gptString}.`)); errs += 1; diff --git a/database-seeds/scripts/test/test-utils.ts b/database-seeds/scripts/test/test-utils.ts index c5bf8db73..b3f2d6d8e 100644 --- a/database-seeds/scripts/test/test-utils.ts +++ b/database-seeds/scripts/test/test-utils.ts @@ -1,7 +1,6 @@ -import { Game } from "tachi-common"; -import { allSupportedGames } from "tachi-common/config/static-config"; -import { SCHEMAS } from "tachi-common/lib/schemas"; +import { Game, allSupportedGames } from "tachi-common"; import { ReadCollection } from "../util"; +import { SCHEMAS } from "tachi-common/lib/schemas"; const songMap = {};